<?xml version='1.0' encoding='utf-8'?>
<FilingSummary>
  <Version>3.24.0.1</Version>
  <ProcessingTime/>
  <ReportFormat>html</ReportFormat>
  <ContextCount>239</ContextCount>
  <ElementCount>400</ElementCount>
  <EntityCount>1</EntityCount>
  <FootnotesReported>false</FootnotesReported>
  <SegmentCount>75</SegmentCount>
  <ScenarioCount>0</ScenarioCount>
  <TuplesReported>false</TuplesReported>
  <UnitCount>8</UnitCount>
  <MyReports>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R1.htm</HtmlFileName>
      <LongName>1001 - Document - Cover Page</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/CoverPage</Role>
      <ShortName>Cover Page</ShortName>
      <MenuCategory>Cover</MenuCategory>
      <Position>1</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R2.htm</HtmlFileName>
      <LongName>1002 - Statement - CONSOLIDATED BALANCE SHEETS</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/ConsolidatedBalanceSheets</Role>
      <ShortName>CONSOLIDATED BALANCE SHEETS</ShortName>
      <MenuCategory>Statements</MenuCategory>
      <Position>2</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R3.htm</HtmlFileName>
      <LongName>1003 - Statement - CONSOLIDATED BALANCE SHEETS (Parenthetical)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/ConsolidatedBalanceSheetsParenthetical</Role>
      <ShortName>CONSOLIDATED BALANCE SHEETS (Parenthetical)</ShortName>
      <MenuCategory>Statements</MenuCategory>
      <Position>3</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R4.htm</HtmlFileName>
      <LongName>1004 - Statement - CONSOLIDATED STATEMENTS OF OPERATIONS</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/ConsolidatedStatementsOfOperations</Role>
      <ShortName>CONSOLIDATED STATEMENTS OF OPERATIONS</ShortName>
      <MenuCategory>Statements</MenuCategory>
      <Position>4</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R5.htm</HtmlFileName>
      <LongName>1005 - Statement - CONSOLIDATED STATEMENTS OF COMPREHENSIVE INCOME (LOSS)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/ConsolidatedStatementsOfComprehensiveIncomeLoss</Role>
      <ShortName>CONSOLIDATED STATEMENTS OF COMPREHENSIVE INCOME (LOSS)</ShortName>
      <MenuCategory>Statements</MenuCategory>
      <Position>5</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R6.htm</HtmlFileName>
      <LongName>1006 - Statement - CONSOLIDATED STATEMENTS OF SHAREHOLDERS' EQUITY</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/ConsolidatedStatementsOfShareholdersEquity</Role>
      <ShortName>CONSOLIDATED STATEMENTS OF SHAREHOLDERS' EQUITY</ShortName>
      <MenuCategory>Statements</MenuCategory>
      <Position>6</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R7.htm</HtmlFileName>
      <LongName>1007 - Statement - CONSOLIDATED STATEMENTS OF CASH FLOWS</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/ConsolidatedStatementsOfCashFlows</Role>
      <ShortName>CONSOLIDATED STATEMENTS OF CASH FLOWS</ShortName>
      <MenuCategory>Statements</MenuCategory>
      <Position>7</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R8.htm</HtmlFileName>
      <LongName>1008 - Disclosure - Summary of Significant Accounting Policies</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/SummaryOfSignificantAccountingPolicies</Role>
      <ShortName>Summary of Significant Accounting Policies</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>8</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R9.htm</HtmlFileName>
      <LongName>1009 - Disclosure - Revenue from Contracts with Customers</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/RevenueFromContractsWithCustomers</Role>
      <ShortName>Revenue from Contracts with Customers</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>9</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R10.htm</HtmlFileName>
      <LongName>1010 - Disclosure - Goodwill and Other Intangible Assets, net</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/GoodwillAndOtherIntangibleAssetsNet</Role>
      <ShortName>Goodwill and Other Intangible Assets, net</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>10</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R11.htm</HtmlFileName>
      <LongName>1011 - Disclosure - Cash and Cash Equivalents</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/CashAndCashEquivalents</Role>
      <ShortName>Cash and Cash Equivalents</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>11</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R12.htm</HtmlFileName>
      <LongName>1012 - Disclosure - Credit Facility</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/CreditFacility</Role>
      <ShortName>Credit Facility</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>12</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R13.htm</HtmlFileName>
      <LongName>1013 - Disclosure - Leases</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/Leases</Role>
      <ShortName>Leases</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>13</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R14.htm</HtmlFileName>
      <LongName>1014 - Disclosure - Long-Term Payroll Tax Liability</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/LongTermPayrollTaxLiability</Role>
      <ShortName>Long-Term Payroll Tax Liability</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>14</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R15.htm</HtmlFileName>
      <LongName>1015 - Disclosure - Commitments and Contingencies</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/CommitmentsAndContingencies</Role>
      <ShortName>Commitments and Contingencies</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>15</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R16.htm</HtmlFileName>
      <LongName>1016 - Disclosure - Employee Benefit Plan</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/EmployeeBenefitPlan</Role>
      <ShortName>Employee Benefit Plan</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>16</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R17.htm</HtmlFileName>
      <LongName>1017 - Disclosure - Stock-Based Compensation</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/StockBasedCompensation</Role>
      <ShortName>Stock-Based Compensation</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>17</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R18.htm</HtmlFileName>
      <LongName>1018 - Disclosure - Income Taxes</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/IncomeTaxes</Role>
      <ShortName>Income Taxes</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>18</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R19.htm</HtmlFileName>
      <LongName>1019 - Disclosure - Shareholders' Equity</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/ShareholdersEquity</Role>
      <ShortName>Shareholders' Equity</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>19</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R20.htm</HtmlFileName>
      <LongName>1020 - Disclosure - Earnings (Loss) per Share</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/EarningsLossPerShare</Role>
      <ShortName>Earnings (Loss) per Share</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>20</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R21.htm</HtmlFileName>
      <LongName>1021 - Disclosure - Other Comprehensive Income (Loss)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/OtherComprehensiveIncomeLoss</Role>
      <ShortName>Other Comprehensive Income (Loss)</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>21</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R22.htm</HtmlFileName>
      <LongName>1022 - Disclosure - Fair Value Measurements</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/FairValueMeasurements</Role>
      <ShortName>Fair Value Measurements</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>22</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R23.htm</HtmlFileName>
      <LongName>1023 - Disclosure - Business Segments and Geographic Information</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/BusinessSegmentsAndGeographicInformation</Role>
      <ShortName>Business Segments and Geographic Information</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>23</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R24.htm</HtmlFileName>
      <LongName>1024 - Disclosure - Related-Party Transactions</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/RelatedPartyTransactions</Role>
      <ShortName>Related-Party Transactions</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>24</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R25.htm</HtmlFileName>
      <LongName>1025 - Disclosure - Subsequent Event</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/SubsequentEvent</Role>
      <ShortName>Subsequent Event</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>25</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R26.htm</HtmlFileName>
      <LongName>1026 - Disclosure - Summary of Significant Accounting Policies (Policies)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/SummaryOfSignificantAccountingPoliciesPolicies</Role>
      <ShortName>Summary of Significant Accounting Policies (Policies)</ShortName>
      <MenuCategory>Policies</MenuCategory>
      <ParentRole>http://www.mastech.com/role/SummaryOfSignificantAccountingPolicies</ParentRole>
      <Position>26</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R27.htm</HtmlFileName>
      <LongName>1027 - Disclosure - Summary of Significant Accounting Policies (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/SummaryOfSignificantAccountingPoliciesTables</Role>
      <ShortName>Summary of Significant Accounting Policies (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.mastech.com/role/SummaryOfSignificantAccountingPolicies</ParentRole>
      <Position>27</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R28.htm</HtmlFileName>
      <LongName>1028 - Disclosure - Revenue from Contracts with Customers (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/RevenueFromContractsWithCustomersTables</Role>
      <ShortName>Revenue from Contracts with Customers (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.mastech.com/role/RevenueFromContractsWithCustomers</ParentRole>
      <Position>28</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R29.htm</HtmlFileName>
      <LongName>1029 - Disclosure - Goodwill and Other Intangible Assets, net (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/GoodwillAndOtherIntangibleAssetsNetTables</Role>
      <ShortName>Goodwill and Other Intangible Assets, net (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.mastech.com/role/GoodwillAndOtherIntangibleAssetsNet</ParentRole>
      <Position>29</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R30.htm</HtmlFileName>
      <LongName>1030 - Disclosure - Leases (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/LeasesTables</Role>
      <ShortName>Leases (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.mastech.com/role/Leases</ParentRole>
      <Position>30</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R31.htm</HtmlFileName>
      <LongName>1031 - Disclosure - Stock-Based Compensation (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/StockBasedCompensationTables</Role>
      <ShortName>Stock-Based Compensation (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.mastech.com/role/StockBasedCompensation</ParentRole>
      <Position>31</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R32.htm</HtmlFileName>
      <LongName>1032 - Disclosure - Income Taxes (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/IncomeTaxesTables</Role>
      <ShortName>Income Taxes (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.mastech.com/role/IncomeTaxes</ParentRole>
      <Position>32</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R33.htm</HtmlFileName>
      <LongName>1033 - Disclosure - Earnings (Loss) per Share  (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/EarningsLossPerShareTables</Role>
      <ShortName>Earnings (Loss) per Share  (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.mastech.com/role/EarningsLossPerShare</ParentRole>
      <Position>33</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R34.htm</HtmlFileName>
      <LongName>1034 - Disclosure - Other Comprehensive Income (Loss) (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/OtherComprehensiveIncomeLossTables</Role>
      <ShortName>Other Comprehensive Income (Loss) (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.mastech.com/role/OtherComprehensiveIncomeLoss</ParentRole>
      <Position>34</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R35.htm</HtmlFileName>
      <LongName>1035 - Disclosure - Fair Value Measurements (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/FairValueMeasurementsTables</Role>
      <ShortName>Fair Value Measurements (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.mastech.com/role/FairValueMeasurements</ParentRole>
      <Position>35</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R36.htm</HtmlFileName>
      <LongName>1036 - Disclosure - Business Segments and Geographic Information (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/BusinessSegmentsAndGeographicInformationTables</Role>
      <ShortName>Business Segments and Geographic Information (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.mastech.com/role/BusinessSegmentsAndGeographicInformation</ParentRole>
      <Position>36</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R37.htm</HtmlFileName>
      <LongName>1037 - Disclosure - Summary of Significant Accounting Policies - Additional Information (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/SummaryOfSignificantAccountingPoliciesAdditionalInformationDetail</Role>
      <ShortName>Summary of Significant Accounting Policies - Additional Information (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>37</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R38.htm</HtmlFileName>
      <LongName>1038 - Disclosure - Summary of Significant Accounting Policies - Schedule of  a Reconciliation of Allowance for Credit Losses (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/SummaryOfSignificantAccountingPoliciesScheduleOfAReconciliationOfAllowanceForCreditLossesDetail</Role>
      <ShortName>Summary of Significant Accounting Policies - Schedule of  a Reconciliation of Allowance for Credit Losses (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>38</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R39.htm</HtmlFileName>
      <LongName>1039 - Disclosure - Summary of Significant Accounting Policies - Estimated Useful Lives of Depreciable Assets (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/SummaryOfSignificantAccountingPoliciesEstimatedUsefulLivesOfDepreciableAssetsDetail</Role>
      <ShortName>Summary of Significant Accounting Policies - Estimated Useful Lives of Depreciable Assets (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>39</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R40.htm</HtmlFileName>
      <LongName>1040 - Disclosure - Revenue from Contracts with Customers - Additional Information (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/RevenueFromContractsWithCustomersAdditionalInformationDetail</Role>
      <ShortName>Revenue from Contracts with Customers - Additional Information (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>40</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R41.htm</HtmlFileName>
      <LongName>1041 - Disclosure - Revenue from Contracts with Customers - Summary of Disaggregation of Our Revenues by Contract Type and Operating Segment (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/RevenueFromContractsWithCustomersSummaryOfDisaggregationOfOurRevenuesByContractTypeAndOperatingSegmentDetail</Role>
      <ShortName>Revenue from Contracts with Customers - Summary of Disaggregation of Our Revenues by Contract Type and Operating Segment (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>41</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R42.htm</HtmlFileName>
      <LongName>1042 - Disclosure - Revenue from Contracts with Customers - Summary of Revenue from External Customers (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/RevenueFromContractsWithCustomersSummaryOfRevenueFromExternalCustomersDetail</Role>
      <ShortName>Revenue from Contracts with Customers - Summary of Revenue from External Customers (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>42</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R43.htm</HtmlFileName>
      <LongName>1043 - Disclosure - Revenue from Contracts with Customers - Summary Of Net Accounts Receivable From Customers, Contract Assets And Contract Liabilities (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/RevenueFromContractsWithCustomersSummaryOfNetAccountsReceivableFromCustomersContractAssetsAndContractLiabilitiesDetail</Role>
      <ShortName>Revenue from Contracts with Customers - Summary Of Net Accounts Receivable From Customers, Contract Assets And Contract Liabilities (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>43</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R44.htm</HtmlFileName>
      <LongName>1044 - Disclosure - Goodwill and Other Intangible Assets, net - Additional Information (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/GoodwillAndOtherIntangibleAssetsNetAdditionalInformationDetail</Role>
      <ShortName>Goodwill and Other Intangible Assets, net - Additional Information (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>44</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R45.htm</HtmlFileName>
      <LongName>1045 - Disclosure - Goodwill and Other Intangible Assets, net - Reconciliation of Goodwill (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/GoodwillAndOtherIntangibleAssetsNetReconciliationOfGoodwillDetail</Role>
      <ShortName>Goodwill and Other Intangible Assets, net - Reconciliation of Goodwill (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>45</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R46.htm</HtmlFileName>
      <LongName>1046 - Disclosure - Goodwill and Other Intangible Assets, net - Components of Identifiable Intangible assets (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/GoodwillAndOtherIntangibleAssetsNetComponentsOfIdentifiableIntangibleAssetsDetail</Role>
      <ShortName>Goodwill and Other Intangible Assets, net - Components of Identifiable Intangible assets (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>46</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R47.htm</HtmlFileName>
      <LongName>1047 - Disclosure - Goodwill and Other Intangible Assets, net - Schedule of Estimated Amortization Expense (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/GoodwillAndOtherIntangibleAssetsNetScheduleOfEstimatedAmortizationExpenseDetail</Role>
      <ShortName>Goodwill and Other Intangible Assets, net - Schedule of Estimated Amortization Expense (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>47</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R48.htm</HtmlFileName>
      <LongName>1048 - Disclosure - Cash and Cash Equivalents - Additional Information (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/CashAndCashEquivalentsAdditionalInformationDetail</Role>
      <ShortName>Cash and Cash Equivalents - Additional Information (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>48</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R49.htm</HtmlFileName>
      <LongName>1049 - Disclosure - Credit Facility - Additional information (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/CreditFacilityAdditionalInformationDetail</Role>
      <ShortName>Credit Facility - Additional information (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>49</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R50.htm</HtmlFileName>
      <LongName>1050 - Disclosure - Leases - Additional Information (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/LeasesAdditionalInformationDetail</Role>
      <ShortName>Leases - Additional Information (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>50</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R51.htm</HtmlFileName>
      <LongName>1051 - Disclosure - Leases - Summary of Balance Sheet classification of lease asset and related lease liability (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/LeasesSummaryOfBalanceSheetClassificationOfLeaseAssetAndRelatedLeaseLiabilityDetail</Role>
      <ShortName>Leases - Summary of Balance Sheet classification of lease asset and related lease liability (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>51</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R52.htm</HtmlFileName>
      <LongName>1052 - Disclosure - Leases - Schedule of Future Minimum Rental Payments for Operating Leases (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/LeasesScheduleOfFutureMinimumRentalPaymentsForOperatingLeasesDetail</Role>
      <ShortName>Leases - Schedule of Future Minimum Rental Payments for Operating Leases (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>52</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R53.htm</HtmlFileName>
      <LongName>1053 - Disclosure - Long-Term Payroll Tax Liability - Additional Information (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/LongTermPayrollTaxLiabilityAdditionalInformationDetail</Role>
      <ShortName>Long-Term Payroll Tax Liability - Additional Information (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>53</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R54.htm</HtmlFileName>
      <LongName>1054 - Disclosure - Commitments and Contingencies - Additional Information (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/CommitmentsAndContingenciesAdditionalInformationDetail</Role>
      <ShortName>Commitments and Contingencies - Additional Information (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>54</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R55.htm</HtmlFileName>
      <LongName>1055 - Disclosure - Employee Benefit Plan - Additional Information (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/EmployeeBenefitPlanAdditionalInformationDetail</Role>
      <ShortName>Employee Benefit Plan - Additional Information (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>55</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R56.htm</HtmlFileName>
      <LongName>1056 - Disclosure - Stock-Based Compensation - Additional Information (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/StockBasedCompensationAdditionalInformationDetail</Role>
      <ShortName>Stock-Based Compensation - Additional Information (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>56</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R57.htm</HtmlFileName>
      <LongName>1057 - Disclosure - Stock-Based Compensation - Summary of Company's Stock Option Activity (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/StockBasedCompensationSummaryOfCompanysStockOptionActivityDetail</Role>
      <ShortName>Stock-Based Compensation - Summary of Company's Stock Option Activity (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>57</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R58.htm</HtmlFileName>
      <LongName>1058 - Disclosure - Stock-Based Compensation - Summary of Information Regarding the Company's Outstanding and Exercisable Stock Options (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/StockBasedCompensationSummaryOfInformationRegardingTheCompanysOutstandingAndExercisableStockOptionsDetail</Role>
      <ShortName>Stock-Based Compensation - Summary of Information Regarding the Company's Outstanding and Exercisable Stock Options (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>58</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R59.htm</HtmlFileName>
      <LongName>1059 - Disclosure - Stock-Based Compensation - Summary of Assumptions with Respect to the Black-Scholes Option Pricing Model (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/StockBasedCompensationSummaryOfAssumptionsWithRespectToTheBlackScholesOptionPricingModelDetail</Role>
      <ShortName>Stock-Based Compensation - Summary of Assumptions with Respect to the Black-Scholes Option Pricing Model (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>59</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R60.htm</HtmlFileName>
      <LongName>1060 - Disclosure - Stock-Based Compensation - Summary of Mastech's Restricted Stock Unit Activity (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/StockBasedCompensationSummaryOfMastechsRestrictedStockUnitActivityDetail</Role>
      <ShortName>Stock-Based Compensation - Summary of Mastech's Restricted Stock Unit Activity (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>60</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R61.htm</HtmlFileName>
      <LongName>1061 - Disclosure - Income Taxes - Components of Income Before Income Taxes (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/IncomeTaxesComponentsOfIncomeBeforeIncomeTaxesDetail</Role>
      <ShortName>Income Taxes - Components of Income Before Income Taxes (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>61</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R62.htm</HtmlFileName>
      <LongName>1062 - Disclosure - Income Taxes - Provision (Benefit) for Income Taxes (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/IncomeTaxesProvisionBenefitForIncomeTaxesDetail</Role>
      <ShortName>Income Taxes - Provision (Benefit) for Income Taxes (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>62</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R63.htm</HtmlFileName>
      <LongName>1063 - Disclosure - Income Taxes - Reconciliation of Income Taxes (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/IncomeTaxesReconciliationOfIncomeTaxesDetail</Role>
      <ShortName>Income Taxes - Reconciliation of Income Taxes (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>63</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R64.htm</HtmlFileName>
      <LongName>1064 - Disclosure - Income Taxes - Components of Deferred Tax Assets and Liabilities (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/IncomeTaxesComponentsOfDeferredTaxAssetsAndLiabilitiesDetail</Role>
      <ShortName>Income Taxes - Components of Deferred Tax Assets and Liabilities (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>64</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R65.htm</HtmlFileName>
      <LongName>1065 - Disclosure - Income Taxes - Additional Information (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/IncomeTaxesAdditionalInformationDetail</Role>
      <ShortName>Income Taxes - Additional Information (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>65</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R66.htm</HtmlFileName>
      <LongName>1066 - Disclosure - Shareholders' Equity - Additional Information (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/ShareholdersEquityAdditionalInformationDetail</Role>
      <ShortName>Shareholders' Equity - Additional Information (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>66</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R67.htm</HtmlFileName>
      <LongName>1067 - Disclosure - Earnings (Loss) per Share - Additional Information (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/EarningsLossPerShareAdditionalInformationDetail</Role>
      <ShortName>Earnings (Loss) per Share - Additional Information (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://www.mastech.com/role/EarningsLossPerShareTables</ParentRole>
      <Position>67</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R68.htm</HtmlFileName>
      <LongName>1068 - Disclosure - Earnings (Loss) per Share  - Schedule of Denominators of Basic and Diluted EPS Computations (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/EarningsLossPerShareScheduleOfDenominatorsOfBasicAndDilutedEpsComputationsDetail</Role>
      <ShortName>Earnings (Loss) per Share  - Schedule of Denominators of Basic and Diluted EPS Computations (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://www.mastech.com/role/EarningsLossPerShareTables</ParentRole>
      <Position>68</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R69.htm</HtmlFileName>
      <LongName>1069 - Disclosure - Earnings (Loss) per Share  - Computation of Basic EPS (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/EarningsLossPerShareComputationOfBasicEpsDetail</Role>
      <ShortName>Earnings (Loss) per Share  - Computation of Basic EPS (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://www.mastech.com/role/EarningsLossPerShareTables</ParentRole>
      <Position>69</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R70.htm</HtmlFileName>
      <LongName>1070 - Disclosure - Earnings (Loss) per Share  - Computation of Diluted EPS (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/EarningsLossPerShareComputationOfDilutedEpsDetail</Role>
      <ShortName>Earnings (Loss) per Share  - Computation of Diluted EPS (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://www.mastech.com/role/EarningsLossPerShareTables</ParentRole>
      <Position>70</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R71.htm</HtmlFileName>
      <LongName>1071 - Disclosure - Other Comprehensive Income (Loss)  - Summary Of Accumulated Other Comprehensive Income (Loss) (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/OtherComprehensiveIncomeLossSummaryOfAccumulatedOtherComprehensiveIncomeLossDetail</Role>
      <ShortName>Other Comprehensive Income (Loss)  - Summary Of Accumulated Other Comprehensive Income (Loss) (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://www.mastech.com/role/OtherComprehensiveIncomeLossTables</ParentRole>
      <Position>71</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R72.htm</HtmlFileName>
      <LongName>1072 - Disclosure - Fair Value Measurements - Additional Information (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/FairValueMeasurementsAdditionalInformationDetail</Role>
      <ShortName>Fair Value Measurements - Additional Information (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>72</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R73.htm</HtmlFileName>
      <LongName>1073 - Disclosure - Fair Value Measurements - Schedule of Changes in Contingent Consideration Liability (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/FairValueMeasurementsScheduleOfChangesInContingentConsiderationLiabilityDetail</Role>
      <ShortName>Fair Value Measurements - Schedule of Changes in Contingent Consideration Liability (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>73</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R74.htm</HtmlFileName>
      <LongName>1074 - Disclosure - Fair Value Measurements - Summary of Financial Assets (Liabilities) at Fair Value Measured on Non-recurring Basis (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/FairValueMeasurementsSummaryOfFinancialAssetsLiabilitiesAtFairValueMeasuredOnNonRecurringBasisDetail</Role>
      <ShortName>Fair Value Measurements - Summary of Financial Assets (Liabilities) at Fair Value Measured on Non-recurring Basis (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>74</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R75.htm</HtmlFileName>
      <LongName>1075 - Disclosure - Business Segments and Geographic Information - Additional Information (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/BusinessSegmentsAndGeographicInformationAdditionalInformationDetail</Role>
      <ShortName>Business Segments and Geographic Information - Additional Information (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>75</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R76.htm</HtmlFileName>
      <LongName>1076 - Disclosure - Business Segments and Geographic Information - Summary of Operating Segments (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/BusinessSegmentsAndGeographicInformationSummaryOfOperatingSegmentsDetail</Role>
      <ShortName>Business Segments and Geographic Information - Summary of Operating Segments (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>76</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R77.htm</HtmlFileName>
      <LongName>1077 - Disclosure - Business Segments and Geographic Information - Summary of Assets by Segment (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/BusinessSegmentsAndGeographicInformationSummaryOfAssetsBySegmentDetail</Role>
      <ShortName>Business Segments and Geographic Information - Summary of Assets by Segment (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>77</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R78.htm</HtmlFileName>
      <LongName>1078 - Disclosure - Business Segments and Geographic Information - Summary of Revenue from External Customers (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/BusinessSegmentsAndGeographicInformationSummaryOfRevenueFromExternalCustomersDetail</Role>
      <ShortName>Business Segments and Geographic Information - Summary of Revenue from External Customers (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>78</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R79.htm</HtmlFileName>
      <LongName>1079 - Disclosure - Related-Party Transactions - Additional Information (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/RelatedPartyTransactionsAdditionalInformationDetail</Role>
      <ShortName>Related-Party Transactions - Additional Information (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>79</Position>
    </Report>
    <Report instance="d636921d10k.htm">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R80.htm</HtmlFileName>
      <LongName>1080 - Disclosure - Subsequent Event - Additional Information (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/SubsequentEventAdditionalInformationDetail</Role>
      <ShortName>Subsequent Event - Additional Information (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>80</Position>
    </Report>
    <Report>
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <LongName>All Reports</LongName>
      <ReportType>Book</ReportType>
      <ShortName>All Reports</ShortName>
    </Report>
  </MyReports>
  <InputFiles>
    <File doctype="10-K" isDefinitelyFs="true" isUsgaap="true" original="d636921d10k.htm">d636921d10k.htm</File>
    <File>mhh-20231231.xsd</File>
    <File>mhh-20231231_cal.xml</File>
    <File>mhh-20231231_def.xml</File>
    <File>mhh-20231231_lab.xml</File>
    <File>mhh-20231231_pre.xml</File>
  </InputFiles>
  <SupplementalFiles>
    <File>g636921g85n48.jpg</File>
  </SupplementalFiles>
  <BaseTaxonomies>
    <BaseTaxonomy items="1033">http://fasb.org/us-gaap/2023</BaseTaxonomy>
    <BaseTaxonomy items="39">http://xbrl.sec.gov/dei/2023</BaseTaxonomy>
  </BaseTaxonomies>
  <HasPresentationLinkbase>true</HasPresentationLinkbase>
  <HasCalculationLinkbase>true</HasCalculationLinkbase>
</FilingSummary>
