<?xml version='1.0' encoding='utf-8'?>
<FilingSummary>
  <Version>3.20.4</Version>
  <ProcessingTime/>
  <ReportFormat>html</ReportFormat>
  <ContextCount>251</ContextCount>
  <ElementCount>500</ElementCount>
  <EntityCount>1</EntityCount>
  <FootnotesReported>false</FootnotesReported>
  <SegmentCount>65</SegmentCount>
  <ScenarioCount>0</ScenarioCount>
  <TuplesReported>false</TuplesReported>
  <UnitCount>7</UnitCount>
  <MyReports>
    <Report instance="mhh-20201231.xml">
      <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="mhh-20201231.xml">
      <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="mhh-20201231.xml">
      <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="mhh-20201231.xml">
      <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="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R5.htm</HtmlFileName>
      <LongName>1005 - Statement - CONSOLIDATED STATEMENTS OF COMPREHENSIVE INCOME</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/ConsolidatedStatementsOfComprehensiveIncome</Role>
      <ShortName>CONSOLIDATED STATEMENTS OF COMPREHENSIVE INCOME</ShortName>
      <MenuCategory>Statements</MenuCategory>
      <Position>5</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <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="mhh-20201231.xml">
      <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="mhh-20201231.xml">
      <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="mhh-20201231.xml">
      <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="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R10.htm</HtmlFileName>
      <LongName>1010 - Disclosure - Business Combinations</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/BusinessCombinations</Role>
      <ShortName>Business Combinations</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>10</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R11.htm</HtmlFileName>
      <LongName>1011 - 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>11</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R12.htm</HtmlFileName>
      <LongName>1012 - 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>12</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R13.htm</HtmlFileName>
      <LongName>1013 - Disclosure - Credit Facility</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/CreditFacility</Role>
      <ShortName>Credit Facility</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>13</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R14.htm</HtmlFileName>
      <LongName>1014 - Disclosure - Leases</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/Leases</Role>
      <ShortName>Leases</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>14</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R15.htm</HtmlFileName>
      <LongName>1015 - 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>15</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R16.htm</HtmlFileName>
      <LongName>1016 - 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>16</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R17.htm</HtmlFileName>
      <LongName>1017 - 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>17</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R18.htm</HtmlFileName>
      <LongName>1018 - 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>18</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R19.htm</HtmlFileName>
      <LongName>1019 - Disclosure - Income Taxes</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/IncomeTaxes</Role>
      <ShortName>Income Taxes</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>19</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R20.htm</HtmlFileName>
      <LongName>1020 - Disclosure - Derivative Instruments and Hedging Activities</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/DerivativeInstrumentsAndHedgingActivities</Role>
      <ShortName>Derivative Instruments and Hedging Activities</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>20</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R21.htm</HtmlFileName>
      <LongName>1021 - Disclosure - Shareholders' Equity</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/ShareholdersEquity</Role>
      <ShortName>Shareholders' Equity</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>21</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R22.htm</HtmlFileName>
      <LongName>1022 - Disclosure - Earnings per Share</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/EarningsPerShare</Role>
      <ShortName>Earnings per Share</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>22</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R23.htm</HtmlFileName>
      <LongName>1023 - 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>23</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R24.htm</HtmlFileName>
      <LongName>1024 - 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>24</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R25.htm</HtmlFileName>
      <LongName>1025 - Disclosure - Quarterly Financial Information</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/QuarterlyFinancialInformation</Role>
      <ShortName>Quarterly Financial Information</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>25</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R26.htm</HtmlFileName>
      <LongName>1026 - 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>26</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R27.htm</HtmlFileName>
      <LongName>1027 - Disclosure - SCHEDULE II-VALUATION AND QUALIFYING ACCOUNTS</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/ScheduleIiValuationAndQualifyingAccounts</Role>
      <ShortName>SCHEDULE II-VALUATION AND QUALIFYING ACCOUNTS</ShortName>
      <MenuCategory>Notes</MenuCategory>
      <Position>27</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R28.htm</HtmlFileName>
      <LongName>1028 - 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>28</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R29.htm</HtmlFileName>
      <LongName>1029 - 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>29</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R30.htm</HtmlFileName>
      <LongName>1030 - 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>30</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R31.htm</HtmlFileName>
      <LongName>1031 - Disclosure - Business Combinations (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/BusinessCombinationsTables</Role>
      <ShortName>Business Combinations (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.mastech.com/role/BusinessCombinations</ParentRole>
      <Position>31</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R32.htm</HtmlFileName>
      <LongName>1032 - 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>32</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R33.htm</HtmlFileName>
      <LongName>1033 - Disclosure - Credit Facility (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/CreditFacilityTables</Role>
      <ShortName>Credit Facility (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.mastech.com/role/CreditFacility</ParentRole>
      <Position>33</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R34.htm</HtmlFileName>
      <LongName>1034 - 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>34</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R35.htm</HtmlFileName>
      <LongName>1035 - 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>35</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R36.htm</HtmlFileName>
      <LongName>1036 - 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>36</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R37.htm</HtmlFileName>
      <LongName>1037 - Disclosure - Derivative Instruments and Hedging Activities (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/DerivativeInstrumentsAndHedgingActivitiesTables</Role>
      <ShortName>Derivative Instruments and Hedging Activities (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.mastech.com/role/DerivativeInstrumentsAndHedgingActivities</ParentRole>
      <Position>37</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R38.htm</HtmlFileName>
      <LongName>1038 - Disclosure - Earnings per Share (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/EarningsPerShareTables</Role>
      <ShortName>Earnings per Share (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.mastech.com/role/EarningsPerShare</ParentRole>
      <Position>38</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R39.htm</HtmlFileName>
      <LongName>1039 - 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>39</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R40.htm</HtmlFileName>
      <LongName>1040 - 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>40</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R41.htm</HtmlFileName>
      <LongName>1041 - Disclosure - Quarterly Financial Information (Tables)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/QuarterlyFinancialInformationTables</Role>
      <ShortName>Quarterly Financial Information (Tables)</ShortName>
      <MenuCategory>Tables</MenuCategory>
      <ParentRole>http://www.mastech.com/role/QuarterlyFinancialInformation</ParentRole>
      <Position>41</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R42.htm</HtmlFileName>
      <LongName>1042 - 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>42</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R43.htm</HtmlFileName>
      <LongName>1043 - 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>43</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R44.htm</HtmlFileName>
      <LongName>1044 - 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>44</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R45.htm</HtmlFileName>
      <LongName>1045 - 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>45</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R46.htm</HtmlFileName>
      <LongName>1046 - 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>46</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R47.htm</HtmlFileName>
      <LongName>1047 - 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>47</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R48.htm</HtmlFileName>
      <LongName>1048 - Disclosure - Business Combinations - Additional Information (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/BusinessCombinationsAdditionalInformationDetail</Role>
      <ShortName>Business Combinations - Additional Information (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>48</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R49.htm</HtmlFileName>
      <LongName>1049 - Disclosure - Business Combinations - Summary of Fair Value of Consideration for Acquired Business (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/BusinessCombinationsSummaryOfFairValueOfConsiderationForAcquiredBusinessDetail</Role>
      <ShortName>Business Combinations - Summary of Fair Value of Consideration for Acquired Business (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>49</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R50.htm</HtmlFileName>
      <LongName>1050 - Disclosure - Business Combinations - Summary of Fair Value of Consideration for Acquired Business (Parenthetical) (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/BusinessCombinationsSummaryOfFairValueOfConsiderationForAcquiredBusinessParentheticalDetail</Role>
      <ShortName>Business Combinations - Summary of Fair Value of Consideration for Acquired Business (Parenthetical) (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>50</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R51.htm</HtmlFileName>
      <LongName>1051 - Disclosure - Business Combinations - Summary of Source of Funds (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/BusinessCombinationsSummaryOfSourceOfFundsDetail</Role>
      <ShortName>Business Combinations - Summary of Source of Funds (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>51</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R52.htm</HtmlFileName>
      <LongName>1052 - Disclosure - Business Combinations - Schedule of Valuation of Net Assets Acquired (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/BusinessCombinationsScheduleOfValuationOfNetAssetsAcquiredDetail</Role>
      <ShortName>Business Combinations - Schedule of Valuation of Net Assets Acquired (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>52</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R53.htm</HtmlFileName>
      <LongName>1053 - Disclosure - Business Combinations - Summary of Unaudited Pro Forma Results (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/BusinessCombinationsSummaryOfUnauditedProFormaResultsDetail</Role>
      <ShortName>Business Combinations - Summary of Unaudited Pro Forma Results (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>53</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R54.htm</HtmlFileName>
      <LongName>1054 - 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>54</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R55.htm</HtmlFileName>
      <LongName>1055 - 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>55</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R56.htm</HtmlFileName>
      <LongName>1056 - Disclosure - Goodwill and Other Intangible Assets - Components of Identifiable Intangible assets (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/GoodwillAndOtherIntangibleAssetsComponentsOfIdentifiableIntangibleAssetsDetail</Role>
      <ShortName>Goodwill and Other Intangible Assets - Components of Identifiable Intangible assets (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>56</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R57.htm</HtmlFileName>
      <LongName>1057 - 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>57</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R58.htm</HtmlFileName>
      <LongName>1058 - 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>58</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R59.htm</HtmlFileName>
      <LongName>1059 - 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>59</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R60.htm</HtmlFileName>
      <LongName>1060 - Disclosure - Credit Facility - Schedule of Annual Aggregate Outstanding Debt (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/CreditFacilityScheduleOfAnnualAggregateOutstandingDebtDetail</Role>
      <ShortName>Credit Facility - Schedule of Annual Aggregate Outstanding Debt (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>60</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R61.htm</HtmlFileName>
      <LongName>1061 - 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>61</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R62.htm</HtmlFileName>
      <LongName>1062 - 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>62</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R63.htm</HtmlFileName>
      <LongName>1063 - 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>63</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R64.htm</HtmlFileName>
      <LongName>1064 - 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>64</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R65.htm</HtmlFileName>
      <LongName>1065 - 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>65</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R66.htm</HtmlFileName>
      <LongName>1066 - 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>66</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R67.htm</HtmlFileName>
      <LongName>1067 - 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>67</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R68.htm</HtmlFileName>
      <LongName>1068 - 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>68</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R69.htm</HtmlFileName>
      <LongName>1069 - 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>69</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R70.htm</HtmlFileName>
      <LongName>1070 - 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>70</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R71.htm</HtmlFileName>
      <LongName>1071 - 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>71</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R72.htm</HtmlFileName>
      <LongName>1072 - Disclosure - Income Taxes - Provision for Income Taxes (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/IncomeTaxesProvisionForIncomeTaxesDetail</Role>
      <ShortName>Income Taxes - Provision for Income Taxes (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>72</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R73.htm</HtmlFileName>
      <LongName>1073 - 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>73</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R74.htm</HtmlFileName>
      <LongName>1074 - 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>74</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R75.htm</HtmlFileName>
      <LongName>1075 - Disclosure - Income Taxes - Unrecognized Tax Benefits Related to Uncertain Tax Positions (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/IncomeTaxesUnrecognizedTaxBenefitsRelatedToUncertainTaxPositionsDetail</Role>
      <ShortName>Income Taxes - Unrecognized Tax Benefits Related to Uncertain Tax Positions (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>75</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R76.htm</HtmlFileName>
      <LongName>1076 - 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>76</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R77.htm</HtmlFileName>
      <LongName>1077 - Disclosure - Derivative Instruments and Hedging Activities - Additional Information (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/DerivativeInstrumentsAndHedgingActivitiesAdditionalInformationDetail</Role>
      <ShortName>Derivative Instruments and Hedging Activities - Additional Information (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>77</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R78.htm</HtmlFileName>
      <LongName>1078 - Disclosure - Derivative Instruments and Hedging Activities - Effect of Derivative Instruments on Consolidated Statements of Operations and Comprehensive Income (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/DerivativeInstrumentsAndHedgingActivitiesEffectOfDerivativeInstrumentsOnConsolidatedStatementsOfOperationsAndComprehensiveIncomeDetail</Role>
      <ShortName>Derivative Instruments and Hedging Activities - Effect of Derivative Instruments on Consolidated Statements of Operations and Comprehensive Income (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>78</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R79.htm</HtmlFileName>
      <LongName>1079 - Disclosure - Derivative Instruments and Hedging Activities - Information on Location and Amounts of Derivative Fair Values in Consolidated Balance Sheets (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/DerivativeInstrumentsAndHedgingActivitiesInformationOnLocationAndAmountsOfDerivativeFairValuesInConsolidatedBalanceSheetsDetail</Role>
      <ShortName>Derivative Instruments and Hedging Activities - Information on Location and Amounts of Derivative Fair Values in Consolidated Balance Sheets (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>79</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R80.htm</HtmlFileName>
      <LongName>1080 - 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>80</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R81.htm</HtmlFileName>
      <LongName>1081 - Disclosure - Earnings per Share - Additional Information (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/EarningsPerShareAdditionalInformationDetail</Role>
      <ShortName>Earnings per Share - Additional Information (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>81</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R82.htm</HtmlFileName>
      <LongName>1082 - Disclosure - Earnings per Share - Schedule of Denominators of Basic and Diluted EPS Computations (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/EarningsPerShareScheduleOfDenominatorsOfBasicAndDilutedEpsComputationsDetail</Role>
      <ShortName>Earnings per Share - Schedule of Denominators of Basic and Diluted EPS Computations (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>82</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R83.htm</HtmlFileName>
      <LongName>1083 - Disclosure - Earnings per Share - Computation of Basic EPS (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/EarningsPerShareComputationOfBasicEpsDetail</Role>
      <ShortName>Earnings per Share - Computation of Basic EPS (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>83</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R84.htm</HtmlFileName>
      <LongName>1084 - Disclosure - Earnings per Share - Computation of Diluted EPS (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/EarningsPerShareComputationOfDilutedEpsDetail</Role>
      <ShortName>Earnings per Share - Computation of Diluted EPS (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>84</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R85.htm</HtmlFileName>
      <LongName>1085 - 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>85</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R86.htm</HtmlFileName>
      <LongName>1086 - 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>86</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R87.htm</HtmlFileName>
      <LongName>1087 - Disclosure - Fair Value Measurements - Summary of Financial Assets (Liabilities) at Fair Value Measured on Recurring Basis (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/FairValueMeasurementsSummaryOfFinancialAssetsLiabilitiesAtFairValueMeasuredOnRecurringBasisDetail</Role>
      <ShortName>Fair Value Measurements - Summary of Financial Assets (Liabilities) at Fair Value Measured on Recurring Basis (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>87</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R88.htm</HtmlFileName>
      <LongName>1088 - 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>88</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R89.htm</HtmlFileName>
      <LongName>1089 - Disclosure - Quarterly Financial Information from Continuing Operations - Summary of Quarterly Financial Information from Continuing Operations (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/QuarterlyFinancialInformationFromContinuingOperationsSummaryOfQuarterlyFinancialInformationFromContinuingOperationsDetail</Role>
      <ShortName>Quarterly Financial Information from Continuing Operations - Summary of Quarterly Financial Information from Continuing Operations (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <Position>89</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R90.htm</HtmlFileName>
      <LongName>1090 - 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>90</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R91.htm</HtmlFileName>
      <LongName>1091 - 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>91</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R92.htm</HtmlFileName>
      <LongName>1092 - 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>92</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R93.htm</HtmlFileName>
      <LongName>1093 - 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>93</Position>
    </Report>
    <Report instance="mhh-20201231.xml">
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <HtmlFileName>R94.htm</HtmlFileName>
      <LongName>1094 - Disclosure - SCHEDULE II-VALUATION AND QUALIFYING ACCOUNTS (Detail)</LongName>
      <ReportType>Sheet</ReportType>
      <Role>http://www.mastech.com/role/ScheduleIiValuationAndQualifyingAccountsDetail</Role>
      <ShortName>SCHEDULE II-VALUATION AND QUALIFYING ACCOUNTS (Detail)</ShortName>
      <MenuCategory>Details</MenuCategory>
      <ParentRole>http://www.mastech.com/role/ScheduleIiValuationAndQualifyingAccounts</ParentRole>
      <Position>94</Position>
    </Report>
    <Report>
      <IsDefault>false</IsDefault>
      <HasEmbeddedReports>false</HasEmbeddedReports>
      <LongName>All Reports</LongName>
      <ReportType>Book</ReportType>
      <ShortName>All Reports</ShortName>
    </Report>
  </MyReports>
  <InputFiles>
    <File>mhh-20201231.xml</File>
    <File>mhh-20201231.xsd</File>
    <File>mhh-20201231_cal.xml</File>
    <File>mhh-20201231_def.xml</File>
    <File>mhh-20201231_lab.xml</File>
    <File>mhh-20201231_pre.xml</File>
  </InputFiles>
  <SupplementalFiles/>
  <BaseTaxonomies>
    <BaseTaxonomy>http://fasb.org/us-gaap/2020-01-31</BaseTaxonomy>
    <BaseTaxonomy>http://fasb.org/srt/2020-01-31</BaseTaxonomy>
    <BaseTaxonomy>http://xbrl.sec.gov/country/2020-01-31</BaseTaxonomy>
    <BaseTaxonomy>http://xbrl.sec.gov/dei/2020-01-31</BaseTaxonomy>
  </BaseTaxonomies>
  <HasPresentationLinkbase>true</HasPresentationLinkbase>
  <HasCalculationLinkbase>true</HasCalculationLinkbase>
</FilingSummary>
