Learn when a custom MCP transport is justified and how to preserve message framing, lifecycle, sessions, security, and interoperability.
A custom MCP transport changes how MCP messages move between a client and server while preserving the protocol’s JSON-RPC messages and lifecycle.Use a custom transport only when stdio and Streamable HTTP cannot meet a real infrastructure requirement. Both the client and server must support the custom mechanism, so it usually reduces interoperability with standard MCP clients.
A custom transport is an advanced extension point. Prefer a standard transport whenever possible.
Protocol compatibility: correct MCP and JSON-RPC behavior
Transport compatibility: a shared way to exchange those messages
A custom transport can preserve protocol semantics, but an ordinary client cannot connect unless it also implements that transport.Document the requirement clearly and provide a standard transport option when broad client support matters.
Requests, responses, and notifications must remain valid JSON-RPC 2.0 messages.Your transport must not change request IDs, method names, parameter shapes, result structures, or error semantics.
Initialization must complete before normal protocol operations. If the underlying channel can reorder messages, your transport needs a strategy to restore the required order.
A custom transport can carry MCP over specialized infrastructure, but both endpoints must support it and preserve the complete MCP lifecycle and JSON-RPC semantics.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"0mcp","description":"Learn how to turn an API into a hosted MCP server with 0mcp.","colors":{"primary":"#E78468","light":"#E78468","dark":"#E78468"},"logo":{"light":"https://mintcdn.com/0mcp/edbyRvIT5oXg-bmk/logo/light.svg?fit=max\u0026auto=format\u0026n=edbyRvIT5oXg-bmk\u0026q=85\u0026s=47de7cdcf15a79f5ed16caffaaad0def","dark":"https://mintcdn.com/0mcp/edbyRvIT5oXg-bmk/logo/dark.svg?fit=max\u0026auto=format\u0026n=edbyRvIT5oXg-bmk\u0026q=85\u0026s=e47198408143a0764045a96c51ff89a5"},"favicon":{"light":"https://mintcdn.com/0mcp/8h2cSvgiqp3fmCjm/favicon-light.svg?fit=max\u0026auto=format\u0026n=8h2cSvgiqp3fmCjm\u0026q=85\u0026s=445edf6c61f65c138b41c76927758f88","dark":"https://mintcdn.com/0mcp/8h2cSvgiqp3fmCjm/favicon-dark.svg?fit=max\u0026auto=format\u0026n=8h2cSvgiqp3fmCjm\u0026q=85\u0026s=7b1062ca254caa729c3e72ab98105fcc"},"appearance":{"default":"dark","strict":true},"navbar":{"links":[{"href":"https://0mcp.io","label":"Website"},{"href":"mailto:[email protected]","label":"Support"}],"primary":{"type":"button","label":"Dashboard","href":"https://0mcp.io/dashboard"}},"footer":{"socials":{"x":"https://x.com/0mcpIO","linkedin":"https://www.linkedin.com/company/0mcp"}},"seo":{"metatags":{"canonical":"https://docs.0mcp.io"},"indexing":"all"},"icons":{"library":"lucide"},"styling":{"eyebrows":"breadcrumbs","latex":false},"contextual":{"options":["copy","view","assistant","mcp","add-mcp"],"display":"header"},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"0mcp","hasAudioNarration":false,"actualSubdomain":"0mcp","customDomains":["docs.0mcp.io"],"gitSource":{"type":"github","owner":"0mcpio","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":false,"mountPath":"","label":""},"chroma":{"collectionId":"c03b4e48-c5f6-4b0e-ba86-b0d8a9caf05c","liveDeploymentHistoryId":"6a7a0140a1755e35467dc5f0","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6a7a0140a1755e35467dc5f0"},"entitlements":{"AI_CHAT":{"status":"DISABLED"}},"buildId":"6a7a0140a1755e35467dc5f0:success","clientVersion":"0.0.4045","searchFilterCounts":[{"language":"default","tag":"Learn MCP","count":40},{"language":"default","tag":"Documentation","count":31},{"language":"default","tag":"Fundamentals","count":15},{"language":"default","tag":"Guides","count":14},{"language":"default","tag":"MCP Best Practices","count":9},{"language":"default","tag":"Build MCP Server","count":6},{"language":"default","tag":"MCP Core Concepts","count":6},{"language":"default","tag":"Setup","count":5},{"language":"default","tag":"API sources","count":4},{"language":"default","tag":"MCP Security","count":4}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[],"googleFontsInlined":false},"customCss":[{"filePath":"style.css","content":"/* vietnamese */\n@font-face {\n font-family: 'Chivo';\n font-style: normal;\n font-weight: 400;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/chivo/v21/va9I4kzIxd1KFrBnQeNHkQ.woff2) format('woff2');\n unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;\n}\n/* latin-ext */\n@font-face {\n font-family: 'Chivo';\n font-style: normal;\n font-weight: 400;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/chivo/v21/va9I4kzIxd1KFrBmQeNHkQ.woff2) format('woff2');\n unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;\n}\n/* latin */\n@font-face {\n font-family: 'Chivo';\n font-style: normal;\n font-weight: 400;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/chivo/v21/va9I4kzIxd1KFrBoQeM.woff2) format('woff2');\n unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;\n}\n/* vietnamese */\n@font-face {\n font-family: 'Chivo';\n font-style: normal;\n font-weight: 500;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/chivo/v21/va9I4kzIxd1KFrBnQeNHkQ.woff2) format('woff2');\n unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;\n}\n/* latin-ext */\n@font-face {\n font-family: 'Chivo';\n font-style: normal;\n font-weight: 500;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/chivo/v21/va9I4kzIxd1KFrBmQeNHkQ.woff2) format('woff2');\n unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;\n}\n/* latin */\n@font-face {\n font-family: 'Chivo';\n font-style: normal;\n font-weight: 500;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/chivo/v21/va9I4kzIxd1KFrBoQeM.woff2) format('woff2');\n unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;\n}\n/* vietnamese */\n@font-face {\n font-family: 'Chivo';\n font-style: normal;\n font-weight: 600;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/chivo/v21/va9I4kzIxd1KFrBnQeNHkQ.woff2) format('woff2');\n unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;\n}\n/* latin-ext */\n@font-face {\n font-family: 'Chivo';\n font-style: normal;\n font-weight: 600;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/chivo/v21/va9I4kzIxd1KFrBmQeNHkQ.woff2) format('woff2');\n unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;\n}\n/* latin */\n@font-face {\n font-family: 'Chivo';\n font-style: normal;\n font-weight: 600;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/chivo/v21/va9I4kzIxd1KFrBoQeM.woff2) format('woff2');\n unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;\n}\n/* vietnamese */\n@font-face {\n font-family: 'Chivo';\n font-style: normal;\n font-weight: 700;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/chivo/v21/va9I4kzIxd1KFrBnQeNHkQ.woff2) format('woff2');\n unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;\n}\n/* latin-ext */\n@font-face {\n font-family: 'Chivo';\n font-style: normal;\n font-weight: 700;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/chivo/v21/va9I4kzIxd1KFrBmQeNHkQ.woff2) format('woff2');\n unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;\n}\n/* latin */\n@font-face {\n font-family: 'Chivo';\n font-style: normal;\n font-weight: 700;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/chivo/v21/va9I4kzIxd1KFrBoQeM.woff2) format('woff2');\n unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;\n}\n/* cyrillic-ext */\n@font-face {\n font-family: 'JetBrains Mono';\n font-style: normal;\n font-weight: 400;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/jetbrainsmono/v24/tDbv2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKwBNntkaToggR7BYRbKPx3cwhsk.woff2) format('woff2');\n unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;\n}\n/* cyrillic */\n@font-face {\n font-family: 'JetBrains Mono';\n font-style: normal;\n font-weight: 400;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/jetbrainsmono/v24/tDbv2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKwBNntkaToggR7BYRbKPxTcwhsk.woff2) format('woff2');\n unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;\n}\n/* greek */\n@font-face {\n font-family: 'JetBrains Mono';\n font-style: normal;\n font-weight: 400;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/jetbrainsmono/v24/tDbv2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKwBNntkaToggR7BYRbKPxPcwhsk.woff2) format('woff2');\n unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;\n}\n/* vietnamese */\n@font-face {\n font-family: 'JetBrains Mono';\n font-style: normal;\n font-weight: 400;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/jetbrainsmono/v24/tDbv2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKwBNntkaToggR7BYRbKPx_cwhsk.woff2) format('woff2');\n unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;\n}\n/* latin-ext */\n@font-face {\n font-family: 'JetBrains Mono';\n font-style: normal;\n font-weight: 400;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/jetbrainsmono/v24/tDbv2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKwBNntkaToggR7BYRbKPx7cwhsk.woff2) format('woff2');\n unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;\n}\n/* latin */\n@font-face {\n font-family: 'JetBrains Mono';\n font-style: normal;\n font-weight: 400;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/jetbrainsmono/v24/tDbv2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKwBNntkaToggR7BYRbKPxDcwg.woff2) format('woff2');\n unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;\n}\n/* cyrillic-ext */\n@font-face {\n font-family: 'JetBrains Mono';\n font-style: normal;\n font-weight: 500;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/jetbrainsmono/v24/tDbv2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKwBNntkaToggR7BYRbKPx3cwhsk.woff2) format('woff2');\n unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;\n}\n/* cyrillic */\n@font-face {\n font-family: 'JetBrains Mono';\n font-style: normal;\n font-weight: 500;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/jetbrainsmono/v24/tDbv2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKwBNntkaToggR7BYRbKPxTcwhsk.woff2) format('woff2');\n unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;\n}\n/* greek */\n@font-face {\n font-family: 'JetBrains Mono';\n font-style: normal;\n font-weight: 500;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/jetbrainsmono/v24/tDbv2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKwBNntkaToggR7BYRbKPxPcwhsk.woff2) format('woff2');\n unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;\n}\n/* vietnamese */\n@font-face {\n font-family: 'JetBrains Mono';\n font-style: normal;\n font-weight: 500;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/jetbrainsmono/v24/tDbv2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKwBNntkaToggR7BYRbKPx_cwhsk.woff2) format('woff2');\n unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;\n}\n/* latin-ext */\n@font-face {\n font-family: 'JetBrains Mono';\n font-style: normal;\n font-weight: 500;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/jetbrainsmono/v24/tDbv2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKwBNntkaToggR7BYRbKPx7cwhsk.woff2) format('woff2');\n unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;\n}\n/* latin */\n@font-face {\n font-family: 'JetBrains Mono';\n font-style: normal;\n font-weight: 500;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/jetbrainsmono/v24/tDbv2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKwBNntkaToggR7BYRbKPxDcwg.woff2) format('woff2');\n unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;\n}\n/* cyrillic-ext */\n@font-face {\n font-family: 'JetBrains Mono';\n font-style: normal;\n font-weight: 600;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/jetbrainsmono/v24/tDbv2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKwBNntkaToggR7BYRbKPx3cwhsk.woff2) format('woff2');\n unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;\n}\n/* cyrillic */\n@font-face {\n font-family: 'JetBrains Mono';\n font-style: normal;\n font-weight: 600;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/jetbrainsmono/v24/tDbv2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKwBNntkaToggR7BYRbKPxTcwhsk.woff2) format('woff2');\n unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;\n}\n/* greek */\n@font-face {\n font-family: 'JetBrains Mono';\n font-style: normal;\n font-weight: 600;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/jetbrainsmono/v24/tDbv2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKwBNntkaToggR7BYRbKPxPcwhsk.woff2) format('woff2');\n unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;\n}\n/* vietnamese */\n@font-face {\n font-family: 'JetBrains Mono';\n font-style: normal;\n font-weight: 600;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/jetbrainsmono/v24/tDbv2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKwBNntkaToggR7BYRbKPx_cwhsk.woff2) format('woff2');\n unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;\n}\n/* latin-ext */\n@font-face {\n font-family: 'JetBrains Mono';\n font-style: normal;\n font-weight: 600;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/jetbrainsmono/v24/tDbv2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKwBNntkaToggR7BYRbKPx7cwhsk.woff2) format('woff2');\n unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;\n}\n/* latin */\n@font-face {\n font-family: 'JetBrains Mono';\n font-style: normal;\n font-weight: 600;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/jetbrainsmono/v24/tDbv2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKwBNntkaToggR7BYRbKPxDcwg.woff2) format('woff2');\n unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;\n}\n/* vietnamese */\n@font-face {\n font-family: 'Space Grotesk';\n font-style: normal;\n font-weight: 400;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/spacegrotesk/v22/V8mDoQDjQSkFtoMM3T6r8E7mPb54C-s0.woff2) format('woff2');\n unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;\n}\n/* latin-ext */\n@font-face {\n font-family: 'Space Grotesk';\n font-style: normal;\n font-weight: 400;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/spacegrotesk/v22/V8mDoQDjQSkFtoMM3T6r8E7mPb94C-s0.woff2) format('woff2');\n unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;\n}\n/* latin */\n@font-face {\n font-family: 'Space Grotesk';\n font-style: normal;\n font-weight: 400;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/spacegrotesk/v22/V8mDoQDjQSkFtoMM3T6r8E7mPbF4Cw.woff2) format('woff2');\n unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;\n}\n/* vietnamese */\n@font-face {\n font-family: 'Space Grotesk';\n font-style: normal;\n font-weight: 500;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/spacegrotesk/v22/V8mDoQDjQSkFtoMM3T6r8E7mPb54C-s0.woff2) format('woff2');\n unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;\n}\n/* latin-ext */\n@font-face {\n font-family: 'Space Grotesk';\n font-style: normal;\n font-weight: 500;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/spacegrotesk/v22/V8mDoQDjQSkFtoMM3T6r8E7mPb94C-s0.woff2) format('woff2');\n unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;\n}\n/* latin */\n@font-face {\n font-family: 'Space Grotesk';\n font-style: normal;\n font-weight: 500;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/spacegrotesk/v22/V8mDoQDjQSkFtoMM3T6r8E7mPbF4Cw.woff2) format('woff2');\n unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;\n}\n/* vietnamese */\n@font-face {\n font-family: 'Space Grotesk';\n font-style: normal;\n font-weight: 600;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/spacegrotesk/v22/V8mDoQDjQSkFtoMM3T6r8E7mPb54C-s0.woff2) format('woff2');\n unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;\n}\n/* latin-ext */\n@font-face {\n font-family: 'Space Grotesk';\n font-style: normal;\n font-weight: 600;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/spacegrotesk/v22/V8mDoQDjQSkFtoMM3T6r8E7mPb94C-s0.woff2) format('woff2');\n unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;\n}\n/* latin */\n@font-face {\n font-family: 'Space Grotesk';\n font-style: normal;\n font-weight: 600;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/spacegrotesk/v22/V8mDoQDjQSkFtoMM3T6r8E7mPbF4Cw.woff2) format('woff2');\n unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;\n}\n/* vietnamese */\n@font-face {\n font-family: 'Space Grotesk';\n font-style: normal;\n font-weight: 700;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/spacegrotesk/v22/V8mDoQDjQSkFtoMM3T6r8E7mPb54C-s0.woff2) format('woff2');\n unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;\n}\n/* latin-ext */\n@font-face {\n font-family: 'Space Grotesk';\n font-style: normal;\n font-weight: 700;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/spacegrotesk/v22/V8mDoQDjQSkFtoMM3T6r8E7mPb94C-s0.woff2) format('woff2');\n unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;\n}\n/* latin */\n@font-face {\n font-family: 'Space Grotesk';\n font-style: normal;\n font-weight: 700;\n font-display: swap;\n src: url(/_mintlify/assets/fonts/google/s/spacegrotesk/v22/V8mDoQDjQSkFtoMM3T6r8E7mPbF4Cw.woff2) format('woff2');\n unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;\n}\n:root{--default-border-color:var(--gray-200);--docs-dashboard-bg:#0b0b0b;--docs-dashboard-sidebar:#0b0b0b;--docs-dashboard-surface:#171717;--docs-dashboard-surface-raised:#171717;--docs-dashboard-border:#171717;--docs-dashboard-border-strong:#171717;--docs-dashboard-text:#f4f4f5;--docs-dashboard-muted:#a3a3a3;--docs-dashboard-subtle:#737373;--docs-dashboard-accent:#e78468;--docs-dashboard-accent-2:#8dcdff}.dark{--default-border-color:var(--gray-800);--gray-50:244 244 245;--gray-100:229 229 229;--gray-200:212 212 212;--gray-300:163 163 163;--gray-400:115 115 115;--gray-500:82 82 82;--gray-600:64 64 64;--gray-700:38 38 38;--gray-800:28 28 28;--gray-900:18 18 18;--gray-950:10 10 10}body,html{font-family:'Space Grotesk',Inter,ui-sans-serif,system-ui,sans-serif!important;background:var(--docs-dashboard-bg)!important;color:var(--docs-dashboard-text)!important}.font-display,.font-heading,[class*=font-serif],h1,h2,h3,h4,h5,h6{font-family:Chivo,'Space Grotesk',Inter,ui-sans-serif,system-ui,sans-serif!important;letter-spacing:0!important}[class*=font-mono],code,kbd,pre,samp{font-family:'JetBrains Mono',ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace!important}header#navbar{background:rgb(11 11 11/.92)!important;border-bottom:1px solid var(--docs-dashboard-border)!important;backdrop-filter:blur(16px)}#sidebar{border-right:1px solid var(--docs-dashboard-border)!important}#navigation-items,#sidebar,#sidebar-content,#sidebar-content>div{background:var(--docs-dashboard-sidebar)!important}#sidebar-content>div>.sticky{background:linear-gradient(to bottom,var(--docs-dashboard-sidebar),rgb(18 18 18/0))!important}#sidebar :is(a, button){border-radius:0!important}#sidebar .nav-anchor,#sidebar .nav-dropdown-trigger{min-height:2.25rem;color:var(--docs-dashboard-muted)!important;font-size:13px!important;transition:background-color 160ms ease,color 160ms ease}#sidebar .nav-anchor:hover,#sidebar .nav-dropdown-trigger:hover{background:rgb(255 255 255/.05)!important;color:var(--docs-dashboard-text)!important}#sidebar a[aria-current=page],#sidebar li[data-active-nav-item=true]>a,#sidebar li[data-active=true]>a{background:rgb(231 132 104/.12)!important;color:var(--docs-dashboard-accent)!important;font-weight:600!important}#sidebar a[aria-current=page] span,#sidebar li[data-active-nav-item=true]>a span,#sidebar li[data-active=true]>a span{color:inherit!important}#sidebar a[aria-current=page] svg,#sidebar li[data-active-nav-item=true]>a svg,#sidebar li[data-active=true]>a svg{color:currentColor!important;background-color:currentColor!important}#sidebar :is(.nav-anchor, .nav-dropdown-trigger) svg,.nav-dropdown-content .nav-dropdown-item-icon{color:currentColor!important}#navigation-items>ul:first-child>li>a.nav-anchor>div:first-child{background:rgb(255 255 255/.03)!important;border:1px solid var(--docs-dashboard-border)!important;color:var(--docs-dashboard-muted)!important;filter:none!important;box-shadow:none!important}#navigation-items>ul:first-child>li>a.nav-anchor{margin-bottom:.2rem!important}#navigation-items>ul:first-child>li>a.nav-anchor>div:first-child svg{background-color:var(--docs-dashboard-muted)!important}#navigation-items>ul:first-child>li>a.nav-anchor:hover>div:first-child{background:rgb(231 132 104/.14)!important;border-color:rgb(231 132 104/.35)!important;color:var(--docs-dashboard-accent)!important}#navigation-items>ul:first-child>li>a.nav-anchor:hover>div:first-child svg{background-color:var(--docs-dashboard-accent)!important}#sidebar .nav-dropdown-trigger{border:0!important;background:0 0!important;box-shadow:none!important;padding-left:.375rem}#sidebar .nav-dropdown-trigger:hover{background-color:rgb(0 0 0/.04)!important}.dark #sidebar .nav-dropdown-trigger:hover{background-color:rgb(255 255 255/.05)!important}#sidebar .nav-dropdown-trigger .nav-dropdown-item-icon,.nav-dropdown-content .nav-dropdown-item-icon{border:0!important;background:0 0!important;height:auto!important;width:auto!important;padding:0!important}.nav-dropdown-content .nav-dropdown-item-description{display:none!important}#sidebar .nav-anchor span{font-family:'Space Grotesk',Inter,ui-sans-serif,system-ui,sans-serif!important;font-size:13px;font-weight:500;letter-spacing:0;text-transform:none}#sidebar [class*=group]>:is(div, span, p),#sidebar p{color:var(--docs-dashboard-muted)!important}#sidebar [class*=font-medium]:has(svg),#sidebar [class*=font-semibold],#sidebar [class*=group]>:is(div, span, p):has(svg){color:var(--docs-dashboard-text)!important}body:has([data-product-guide-index]) #sidebar a.nav-anchor[href='/']{background:rgb(255 255 255/.1)!important;color:var(--docs-dashboard-text)!important;font-weight:600!important}body:has([data-product-guide-index]) #sidebar a.nav-anchor[href='/'] span{color:inherit!important}.dark body:has([data-product-guide-index]) #sidebar a.nav-anchor[href='/'] svg,body:has([data-product-guide-index]) #sidebar a.nav-anchor[href='/'] svg{background-color:var(--docs-dashboard-text)!important}.dark body:has([data-product-guide-index]) #sidebar a.nav-anchor[href='/']{color:var(--docs-dashboard-text)!important}:is(#content-area[data-current-path='/'], [data-current-path='/'] #content-area):has([data-product-guide-index]){background:0 0!important}:is(#content-area[data-current-path='/'], [data-current-path='/'] #content-area):has([data-product-guide-index])>div:first-child{background:0 0!important;padding-right:0!important;padding-bottom:0!important;padding-left:0!important}[data-product-guide-index] a:not(.product-guide-feature-card){background-color:var(--docs-dashboard-surface)!important;border:1px solid var(--docs-dashboard-border)!important;border-radius:0!important;box-shadow:none!important}.dark [data-product-guide-index] a:not(.product-guide-feature-card){background-color:var(--docs-dashboard-surface)!important}[data-product-guide-index] a:not(.product-guide-feature-card):hover{background-color:var(--docs-dashboard-surface-raised)!important;border-color:var(--docs-dashboard-border-strong)!important}[data-product-guide-index]{color:var(--docs-dashboard-text)!important}[data-product-guide-index] h1{font-size:2rem!important;font-weight:600!important;line-height:1.15!important}[data-product-guide-index] :is(p, span, div){letter-spacing:0!important}[data-product-guide-index] :is(p, span[class*='text-gray-600'], span[class*='text-gray-400']){color:var(--docs-dashboard-muted)!important}.product-guide-feature-card,.product-guide-feature-card>div{display:flex!important;flex-direction:column!important;justify-content:space-between!important}.product-guide-feature-card{grid-column:1/-1;min-height:260px;background:url(/images/sample-feature-light.png) center/cover no-repeat!important;border:1px solid var(--docs-dashboard-border)!important;border-radius:0!important;box-shadow:none!important;color:#fff!important}.product-guide-feature-card>div{flex:1}.product-guide-feature-card :is(h2, h3, p, span, svg){color:#fff!important}.product-guide-feature-card :is(svg, [class*='icon']){background-color:#fff!important;width:2em!important;height:2em!important;margin-top:2px}.product-guide-feature-card-title{font-size:1.2em;font-weight:500}.product-guide-feature-card :is(h2, h3, p, span, svg).product-guide-feature-card-description{font-size:1.05em;font-weight:400;color:rgb(var(--gray-50)/62.5%)!important}img.nav-logo{width:120px;max-width:120px;max-height:40px;height:auto;object-fit:contain}:is(.card, [class*='rounded-'], button, input, textarea, select, kbd, pre, code){border-radius:0!important}:is(input, textarea, select, [role='combobox']){background:var(--docs-dashboard-surface)!important;border-color:var(--docs-dashboard-border)!important;color:var(--docs-dashboard-text)!important}.card,:is(button, a)[class*=border],[data-component-part=card-content-container]{border-color:var(--docs-dashboard-border)!important;box-shadow:none!important}#content :is(.card, [data-component-part='card-content-container']){background-color:var(--docs-dashboard-surface)!important}#content a.card:hover,#content a:has(>[data-component-part=card-content-container]):hover [data-component-part=card-content-container]{background-color:var(--docs-dashboard-surface-raised)!important;border-color:var(--docs-dashboard-border-strong)!important}#content,#content-area{background:var(--docs-dashboard-bg)!important}#content :is(p, li, td, blockquote){color:var(--docs-dashboard-muted)}#content :is(h1, h2, h3, h4){color:var(--docs-dashboard-text)}#content a{text-decoration-color:rgb(231 132 104/.55);text-underline-offset:4px}"}],"page":{"pagePath":"learn/fundamentals/custom-mcp-transport","slug":"/learn/fundamentals/custom-mcp-transport","pageMetadata":{"title":"Custom MCP transport implementation","description":"Learn when a custom MCP transport is justified and how to preserve message framing, lifecycle, sessions, security, and interoperability.","href":"/learn/fundamentals/custom-mcp-transport"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Learn when a custom MCP transport is justified and how to preserve message framing, lifecycle, sessions, security, and interoperability.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`A `,_jsxs(_components.strong,{children:[`custom `,_jsx(_components.a,{href:`https://modelcontextprotocol.io/specification`,children:`MCP transport`})]}),` changes how MCP messages move between a client and server while preserving the protocol’s JSON-RPC messages and lifecycle.`]}),`\n`,_jsxs(_components.p,{children:[`Use a custom transport only when `,_jsx(_components.code,{children:`stdio`}),` and Streamable HTTP cannot meet a real infrastructure requirement. Both the client and server must support the custom mechanism, so it usually reduces interoperability with standard MCP clients.`]}),`\n`,_jsx(Warning,{children:_jsx(_components.p,{children:`A custom transport is an advanced extension point. Prefer a standard transport whenever possible.`})}),`\n`,_jsx(Heading,{level:`2`,id:`standard-mcp-transports`,children:`Standard MCP transports`}),`\n`,_jsx(_components.p,{children:`The MCP specification defines two standard transports:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`stdio`}),` for a client communicating with a local server process`]}),`\n`,_jsx(_components.li,{children:`Streamable HTTP for a client communicating with a network service`}),`\n`]}),`\n`,_jsx(_components.p,{children:`These cover most local and remote deployments. Standard transports also receive the broadest SDK, client, Inspector, and documentation support.`}),`\n`,_jsx(Heading,{level:`2`,id:`when-a-custom-transport-may-make-sense`,children:`When a custom transport may make sense`}),`\n`,_jsx(_components.p,{children:`A custom transport may be justified when you must:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`Use an existing enterprise message bus`}),`\n`,_jsx(_components.li,{children:`Cross a specialized network boundary`}),`\n`,_jsx(_components.li,{children:`Integrate with a proprietary application runtime`}),`\n`,_jsx(_components.li,{children:`Meet a hard real-time or low-latency constraint`}),`\n`,_jsxs(_components.li,{children:[`Use a communication channel unavailable through HTTP or `,_jsx(_components.code,{children:`stdio`})]}),`\n`,_jsx(_components.li,{children:`Apply organization-specific framing or routing`}),`\n`]}),`\n`,_jsx(_components.p,{children:`Convenience alone is rarely enough. First consider adapting the existing infrastructure to Streamable HTTP.`}),`\n`,_jsx(Heading,{level:`2`,id:`interoperability-tradeoff`,children:`Interoperability tradeoff`}),`\n`,_jsx(_components.p,{children:`MCP compatibility has two layers:`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsx(_components.li,{children:`Protocol compatibility: correct MCP and JSON-RPC behavior`}),`\n`,_jsx(_components.li,{children:`Transport compatibility: a shared way to exchange those messages`}),`\n`]}),`\n`,_jsx(_components.p,{children:`A custom transport can preserve protocol semantics, but an ordinary client cannot connect unless it also implements that transport.`}),`\n`,_jsx(_components.p,{children:`Document the requirement clearly and provide a standard transport option when broad client support matters.`}),`\n`,_jsx(Heading,{level:`2`,id:`core-implementation-requirements`,children:`Core implementation requirements`}),`\n`,_jsx(Heading,{level:`3`,id:`preserve-json-rpc-messages`,children:`Preserve JSON-RPC messages`}),`\n`,_jsx(_components.p,{children:`Requests, responses, and notifications must remain valid JSON-RPC 2.0 messages.`}),`\n`,_jsx(_components.p,{children:`Your transport must not change request IDs, method names, parameter shapes, result structures, or error semantics.`}),`\n`,_jsx(Heading,{level:`3`,id:`define-message-framing`,children:`Define message framing`}),`\n`,_jsx(_components.p,{children:`The receiver must know where one message ends and another begins.`}),`\n`,_jsx(_components.p,{children:`Possible framing strategies include:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`Length-prefixed frames`}),`\n`,_jsx(_components.li,{children:`One message per queue record`}),`\n`,_jsx(_components.li,{children:`One message per WebSocket frame`}),`\n`,_jsx(_components.li,{children:`Delimiter-based messages with strict escaping`}),`\n`]}),`\n`,_jsx(_components.p,{children:`Do not assume that one network read equals one complete message.`}),`\n`,_jsx(Heading,{level:`3`,id:`preserve-ordering-rules`,children:`Preserve ordering rules`}),`\n`,_jsx(_components.p,{children:`Initialization must complete before normal protocol operations. If the underlying channel can reorder messages, your transport needs a strategy to restore the required order.`}),`\n`,_jsx(Heading,{level:`3`,id:`correlate-requests-and-responses`,children:`Correlate requests and responses`}),`\n`,_jsx(_components.p,{children:`JSON-RPC IDs associate responses with requests. The transport must preserve them across concurrency, retries, reconnections, and routing layers.`}),`\n`,_jsx(Heading,{level:`3`,id:`handle-notifications`,children:`Handle notifications`}),`\n`,_jsx(_components.p,{children:`Notifications do not receive responses. Your implementation must deliver them without waiting for a reply or generating a synthetic one.`}),`\n`,_jsx(Heading,{level:`3`,id:`define-connection-and-session-behavior`,children:`Define connection and session behavior`}),`\n`,_jsx(_components.p,{children:`Specify:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`How a client connects`}),`\n`,_jsx(_components.li,{children:`How authentication occurs`}),`\n`,_jsx(_components.li,{children:`When a session begins`}),`\n`,_jsx(_components.li,{children:`How session identity is represented`}),`\n`,_jsx(_components.li,{children:`How reconnection works`}),`\n`,_jsx(_components.li,{children:`When resources are released`}),`\n`,_jsx(_components.li,{children:`What happens after partial failure`}),`\n`]}),`\n`,_jsx(_components.p,{children:`Unclear session behavior creates subtle protocol bugs.`}),`\n`,_jsx(Heading,{level:`2`,id:`conceptual-transport-interface`,children:`Conceptual transport interface`}),`\n`,_jsx(_components.p,{children:`The exact SDK interface varies, but a transport generally needs operations like:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`6`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`6`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`connect()`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`send(message)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`receive(message)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`close()`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`onError(error)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(_components.p,{children:`The transport should pass decoded MCP messages to the protocol layer and keep routing details out of tool implementations.`}),`\n`,_jsx(Heading,{level:`2`,id:`reliability-design`,children:`Reliability design`}),`\n`,_jsx(_components.p,{children:`Plan for:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`Timeouts`}),`\n`,_jsx(_components.li,{children:`Backpressure`}),`\n`,_jsx(_components.li,{children:`Bounded queues`}),`\n`,_jsx(_components.li,{children:`Duplicate delivery`}),`\n`,_jsx(_components.li,{children:`Lost connections`}),`\n`,_jsx(_components.li,{children:`Retry rules`}),`\n`,_jsx(_components.li,{children:`Cancellation`}),`\n`,_jsx(_components.li,{children:`Graceful shutdown`}),`\n`,_jsx(_components.li,{children:`Maximum message size`}),`\n`]}),`\n`,_jsx(_components.p,{children:`Automatic retries are dangerous for write operations. Use idempotency controls when the underlying operation can change state.`}),`\n`,_jsx(Heading,{level:`2`,id:`security-design`,children:`Security design`}),`\n`,_jsx(_components.p,{children:`A custom transport creates a new attack surface.`}),`\n`,_jsx(_components.p,{children:`Define:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`Peer authentication`}),`\n`,_jsx(_components.li,{children:`Message confidentiality`}),`\n`,_jsx(_components.li,{children:`Message integrity`}),`\n`,_jsx(_components.li,{children:`Authorization boundaries`}),`\n`,_jsx(_components.li,{children:`Replay protection`}),`\n`,_jsx(_components.li,{children:`Secret storage`}),`\n`,_jsx(_components.li,{children:`Audit logging`}),`\n`,_jsx(_components.li,{children:`Resource limits`}),`\n`]}),`\n`,_jsx(_components.p,{children:`Do not invent cryptography. Use established secure channels and identity systems.`}),`\n`,_jsx(Heading,{level:`2`,id:`test-the-custom-transport`,children:`Test the custom transport`}),`\n`,_jsx(_components.p,{children:`Test at several levels:`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsx(_components.li,{children:`Unit-test framing and parsing.`}),`\n`,_jsx(_components.li,{children:`Test fragmented and combined messages.`}),`\n`,_jsx(_components.li,{children:`Test concurrent requests with different IDs.`}),`\n`,_jsx(_components.li,{children:`Test notifications.`}),`\n`,_jsx(_components.li,{children:`Test invalid JSON-RPC messages.`}),`\n`,_jsx(_components.li,{children:`Test initialization failures.`}),`\n`,_jsx(_components.li,{children:`Test disconnects and reconnection.`}),`\n`,_jsx(_components.li,{children:`Test cancellation and timeouts.`}),`\n`,_jsx(_components.li,{children:`Test authentication failures.`}),`\n`,_jsx(_components.li,{children:`Run compatibility tests against every supported client and server.`}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`The standard `,_jsx(_components.a,{href:`/learn/fundamentals/mcp-inspector-guide`,children:`MCP Inspector`}),` will not automatically understand a proprietary transport. Build an adapter or a dedicated test client.`]}),`\n`,_jsx(Heading,{level:`2`,id:`when-to-stop-and-use-streamable-http`,children:`When to stop and use Streamable HTTP`}),`\n`,_jsx(_components.p,{children:`Prefer Streamable HTTP when:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`Existing clients must connect without modification`}),`\n`,_jsx(_components.li,{children:`The server is reachable over ordinary web infrastructure`}),`\n`,_jsx(_components.li,{children:`Standard authentication and proxies are sufficient`}),`\n`,_jsx(_components.li,{children:`You want Inspector support`}),`\n`,_jsx(_components.li,{children:`Your team does not want to maintain client-side transport code`}),`\n`]}),`\n`,_jsx(_components.p,{children:`Custom transport maintenance continues for the lifetime of every supported client.`}),`\n`,_jsx(Heading,{level:`2`,id:`key-takeaway`,children:`Key takeaway`}),`\n`,_jsx(_components.p,{children:_jsx(_components.strong,{children:`A custom transport can carry MCP over specialized infrastructure, but both endpoints must support it and preserve the complete MCP lifecycle and JSON-RPC semantics.`})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Custom MCP transport implementation","description":"Learn when a custom MCP transport is justified and how to preserve message framing, lifecycle, sessions, security, and interoperability.","href":"/learn/fundamentals/custom-mcp-transport"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Standard MCP transports","slug":"standard-mcp-transports","depth":2,"children":[]},{"title":"When a custom transport may make sense","slug":"when-a-custom-transport-may-make-sense","depth":2,"children":[]},{"title":"Interoperability tradeoff","slug":"interoperability-tradeoff","depth":2,"children":[]},{"title":"Core implementation requirements","slug":"core-implementation-requirements","depth":2,"children":[{"title":"Preserve JSON-RPC messages","slug":"preserve-json-rpc-messages","depth":3,"children":[]},{"title":"Define message framing","slug":"define-message-framing","depth":3,"children":[]},{"title":"Preserve ordering rules","slug":"preserve-ordering-rules","depth":3,"children":[]},{"title":"Correlate requests and responses","slug":"correlate-requests-and-responses","depth":3,"children":[]},{"title":"Handle notifications","slug":"handle-notifications","depth":3,"children":[]},{"title":"Define connection and session behavior","slug":"define-connection-and-session-behavior","depth":3,"children":[]}]},{"title":"Conceptual transport interface","slug":"conceptual-transport-interface","depth":2,"children":[]},{"title":"Reliability design","slug":"reliability-design","depth":2,"children":[]},{"title":"Security design","slug":"security-design","depth":2,"children":[]},{"title":"Test the custom transport","slug":"test-the-custom-transport","depth":2,"children":[]},{"title":"When to stop and use Streamable HTTP","slug":"when-to-stop-and-use-streamable-http","depth":2,"children":[]},{"title":"Key takeaway","slug":"key-takeaway","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"0mcp","siteName":"0mcp","title":"Custom MCP transport implementation - 0mcp","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-08-03T05:44:20.502Z","originalFileLocation":"learn/fundamentals/custom-mcp-transport.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=\"dark\";if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"dark\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Learn when a custom MCP transport is justified and how to preserve message framing, lifecycle, sessions, security, and interoperability.\">\u003cmeta data-mint-head name=\"application-name\" content=\"0mcp\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/0mcp/mSqqq78mYLc8FuRB/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/0mcp/mSqqq78mYLc8FuRB/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/0mcp/mSqqq78mYLc8FuRB/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/0mcp/mSqqq78mYLc8FuRB/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/0mcp/mSqqq78mYLc8FuRB/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/0mcp/mSqqq78mYLc8FuRB/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/0mcp/mSqqq78mYLc8FuRB/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/0mcp/mSqqq78mYLc8FuRB/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/0mcp/mSqqq78mYLc8FuRB/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Custom MCP transport implementation - 0mcp\">\u003cmeta data-mint-head property=\"og:description\" content=\"Learn when a custom MCP transport is justified and how to preserve message framing, lifecycle, sessions, security, and interoperability.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"0mcp\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.0mcp.io/learn/fundamentals/custom-mcp-transport\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://0mcp.mintlify.app/_mintlify/api/og/v2?division=Fundamentals\u0026amp;title=Custom+MCP+transport+implementation\u0026amp;description=Learn+when+a+custom+MCP+transport+is+justified+and+how+to+preserve+message+framing%2C+lifecycle%2C+sessions%2C+security%2C+and+interoperability.\u0026amp;theme=52af35900aee7951d12e3584\u0026amp;signature=94864604cda0c7199e9b6a60b3ff047f19cad1f9ef246b9aedeb157a7ee0b450\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Custom MCP transport implementation - 0mcp\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Learn when a custom MCP transport is justified and how to preserve message framing, lifecycle, sessions, security, and interoperability.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://0mcp.mintlify.app/_mintlify/api/og/v2?division=Fundamentals\u0026amp;title=Custom+MCP+transport+implementation\u0026amp;description=Learn+when+a+custom+MCP+transport+is+justified+and+how+to+preserve+message+framing%2C+lifecycle%2C+sessions%2C+security%2C+and+interoperability.\u0026amp;theme=52af35900aee7951d12e3584\u0026amp;signature=94864604cda0c7199e9b6a60b3ff047f19cad1f9ef246b9aedeb157a7ee0b450\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/0mcp/mSqqq78mYLc8FuRB/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"0mcp\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#E78468\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.0mcp.io/learn/fundamentals/custom-mcp-transport\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/learn/fundamentals/custom-mcp-transport.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.0mcp.io/#organization\",\"name\":\"0mcp\",\"url\":\"https://docs.0mcp.io\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/0mcp/edbyRvIT5oXg-bmk/logo/light.svg?fit=max\u0026auto=format\u0026n=edbyRvIT5oXg-bmk\u0026q=85\u0026s=47de7cdcf15a79f5ed16caffaaad0def\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.0mcp.io#website\",\"name\":\"0mcp\",\"url\":\"https://docs.0mcp.io\",\"publisher\":{\"@id\":\"https://docs.0mcp.io/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.0mcp.io/learn/fundamentals/custom-mcp-transport#webpage\",\"url\":\"https://docs.0mcp.io/learn/fundamentals/custom-mcp-transport\",\"name\":\"Custom MCP transport implementation\",\"description\":\"Learn when a custom MCP transport is justified and how to preserve message framing, lifecycle, sessions, security, and interoperability.\",\"dateModified\":\"2026-08-03T05:44:20.502Z\",\"isPartOf\":{\"@id\":\"https://docs.0mcp.io#website\"},\"breadcrumb\":{\"@id\":\"https://docs.0mcp.io/learn/fundamentals/custom-mcp-transport#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.0mcp.io/learn/fundamentals/custom-mcp-transport#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Fundamentals\",\"item\":\"https://docs.0mcp.io/learn/fundamentals/what-is-mcp\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Custom MCP transport implementation\",\"item\":\"https://docs.0mcp.io/learn/fundamentals/custom-mcp-transport\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.0mcp.io/learn/fundamentals/custom-mcp-transport#article\",\"headline\":\"Custom MCP transport implementation\",\"name\":\"Custom MCP transport implementation\",\"description\":\"Learn when a custom MCP transport is justified and how to preserve message framing, lifecycle, sessions, security, and interoperability.\",\"url\":\"https://docs.0mcp.io/learn/fundamentals/custom-mcp-transport\",\"mainEntityOfPage\":{\"@id\":\"https://docs.0mcp.io/learn/fundamentals/custom-mcp-transport#webpage\"},\"dateModified\":\"2026-08-03T05:44:20.502Z\",\"publisher\":{\"@id\":\"https://docs.0mcp.io/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.0mcp.io#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"0mcp\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"0mcp","nav":{"global":null,"tabs":[{"tab":"Documentation","pages":[{"title":"Documentation","href":""}]},{"tab":"Learn MCP","pages":[{"group":"Fundamentals","icon":"book-open","pages":[{"title":"What is MCP?","href":"/learn/fundamentals/what-is-mcp"},{"title":"Why MCP matters?","href":"/learn/fundamentals/why-mcp-matters"},{"title":"How MCP works?","href":"/learn/fundamentals/how-mcp-works"},{"title":"MCP architecture explained","href":"/learn/fundamentals/mcp-architecture-explained"},{"title":"Remote MCP servers","href":"/learn/fundamentals/remote-mcp-servers"},{"title":"Local MCP servers","href":"/learn/fundamentals/local-mcp-servers"},{"title":"Local vs remote MCP: Which should you choose?","href":"/learn/fundamentals/local-vs-remote-mcp"},{"title":"The MCP specification explained","description":"Learn how the Model Context Protocol specification defines messages, lifecycle, transports, features, versioning, and security requirements.","href":"/learn/fundamentals/mcp-specification-explained"},{"title":"Custom MCP transport implementation","href":"/learn/fundamentals/custom-mcp-transport"},{"title":"Deploying an MCP server on Kubernetes","description":"Deploy a remote MCP server on Kubernetes with containers, Services, Ingress, secrets, health checks, scaling, observability, and least-privilege security.","href":"/learn/fundamentals/mcp-server-on-kubernetes"},{"title":"How to use Claude with MCP","href":"/learn/fundamentals/using-claude-with-mcp"},{"title":"MCP vs traditional AI SDKs: What builders should know","href":"/learn/fundamentals/mcp-vs-traditional-sdks"},{"title":"Comparing MCP SDKs: Python vs TypeScript vs Go","href":"/learn/fundamentals/mcp-sdk-comparison"},{"title":"MCP Inspector: A guide to testing and debugging","href":"/learn/fundamentals/mcp-inspector-guide"},{"title":"RAG vs MCP: Differences and when to combine them","href":"/learn/fundamentals/rag-vs-mcp"}]},{"group":"MCP Core Concepts","icon":"blocks","pages":[{"title":"Hosts, clients, and servers in MCP","href":"/learn/core-concepts/hosts-clients-servers"},{"title":"Tools","href":"/learn/core-concepts/tools"},{"title":"Resources","href":"/learn/core-concepts/resources"},{"title":"Prompts","href":"/learn/core-concepts/prompts"},{"title":"Sampling","href":"/learn/core-concepts/sampling"},{"title":"Transports","href":"/learn/core-concepts/transports"}]},{"group":"Build MCP Server","icon":"hammer","pages":[{"title":"Turning OpenAPI specs into MCP servers","href":"/learn/build/openapi-to-mcp-server"},{"title":"From REST API to MCP server: A migration guide","href":"/learn/build/rest-api-to-mcp-server"},{"title":"MCP server generators: Tools compared","href":"/learn/build/mcp-server-generators"},{"title":"The MCP TypeScript SDK: Building clients and servers","href":"/learn/build/typescript-sdk"},{"title":"The MCP Python SDK: Building clients and servers","href":"/learn/build/python-sdk"},{"title":"How the MCP ecosystem is evolving","href":"/learn/build/mcp-ecosystem-evolution"}]},{"group":"MCP Security","icon":"shield-check","pages":[{"title":"MCP Server Security","href":"/learn/security/mcp-server-security"},{"title":"MCP authentication","href":"/learn/security/authentication"},{"title":"MCP authorization","href":"/learn/security/authorization"},{"title":"API key management best practices for MCP servers","href":"/learn/security/api-key-management"}]},{"group":"MCP Best Practices","icon":"list-checks","pages":[{"title":"Real-time monitoring and logging for MCP servers","href":"/learn/best-practices/monitoring-and-logging"},{"title":"How to test an MCP server","href":"/learn/best-practices/how-to-test-mcp-servers"},{"title":"Error handling and debugging for MCP servers","href":"/learn/best-practices/error-handling-and-debugging"},{"title":"MCP API documentation guide","href":"/learn/best-practices/api-documentation-guide"},{"title":"MCP server configuration best practices","href":"/learn/best-practices/server-configuration"},{"title":"MCP server prompting guide","href":"/learn/best-practices/server-prompting-guide"},{"title":"10 useful MCP servers for developers","href":"/learn/best-practices/best-mcp-servers"},{"title":"MCP streaming performance and transport trade-offs","href":"/learn/best-practices/streaming-performance-tradeoffs"},{"title":"MCP server architecture for API providers","href":"/learn/best-practices/architecture-for-api-providers"}]}]}]},"basePath":"","title":"Custom MCP transport implementation - 0mcp","buildId":"dpl_36EDyZCDfRuoUD9af5CH4M1bqY2h","deploymentId":"dpl_36EDyZCDfRuoUD9af5CH4M1bqY2h","dynamics":[],"chunks":[]}