@j0hanz/filesystem-mcp 1.19.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +333 -838
- package/dist/cli-help.d.ts +3 -0
- package/dist/cli-help.d.ts.map +1 -0
- package/dist/cli-help.js +169 -0
- package/dist/cli-help.js.map +1 -0
- package/dist/cli.d.ts +28 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +168 -123
- package/dist/cli.js.map +1 -0
- package/dist/core/concurrency.d.ts +70 -0
- package/dist/core/concurrency.d.ts.map +1 -0
- package/dist/core/concurrency.js +173 -0
- package/dist/core/concurrency.js.map +1 -0
- package/dist/core/config.d.ts +19 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +11 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/cursor.d.ts +23 -0
- package/dist/core/cursor.d.ts.map +1 -0
- package/dist/core/cursor.js +62 -0
- package/dist/core/cursor.js.map +1 -0
- package/dist/core/errors.d.ts +96 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +356 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/file-uri.d.ts +24 -0
- package/dist/core/file-uri.d.ts.map +1 -0
- package/dist/core/file-uri.js +52 -0
- package/dist/core/file-uri.js.map +1 -0
- package/dist/core/fmt.d.ts +38 -0
- package/dist/core/fmt.d.ts.map +1 -0
- package/dist/core/fmt.js +109 -0
- package/dist/core/fmt.js.map +1 -0
- package/dist/core/fs.d.ts +108 -0
- package/dist/core/fs.d.ts.map +1 -0
- package/dist/core/fs.js +243 -0
- package/dist/core/fs.js.map +1 -0
- package/dist/core/glob.d.ts +41 -0
- package/dist/core/glob.d.ts.map +1 -0
- package/dist/core/glob.js +399 -0
- package/dist/core/glob.js.map +1 -0
- package/dist/core/input-required.d.ts +147 -0
- package/dist/core/input-required.d.ts.map +1 -0
- package/dist/core/input-required.js +261 -0
- package/dist/core/input-required.js.map +1 -0
- package/dist/core/mime.d.ts +15 -0
- package/dist/core/mime.d.ts.map +1 -0
- package/dist/core/mime.js +188 -0
- package/dist/core/mime.js.map +1 -0
- package/dist/core/observability.d.ts +10 -0
- package/dist/core/observability.d.ts.map +1 -0
- package/dist/core/observability.js +76 -0
- package/dist/core/observability.js.map +1 -0
- package/dist/core/page-store.d.ts +41 -0
- package/dist/core/page-store.d.ts.map +1 -0
- package/dist/core/page-store.js +74 -0
- package/dist/core/page-store.js.map +1 -0
- package/dist/core/path-completer.d.ts +10 -0
- package/dist/core/path-completer.d.ts.map +1 -0
- package/dist/core/path-completer.js +227 -0
- package/dist/core/path-completer.js.map +1 -0
- package/dist/core/path-discovery.d.ts +8 -0
- package/dist/core/path-discovery.d.ts.map +1 -0
- package/dist/core/path-discovery.js +105 -0
- package/dist/core/path-discovery.js.map +1 -0
- package/dist/core/path-utils.d.ts +9 -0
- package/dist/core/path-utils.d.ts.map +1 -0
- package/dist/core/path-utils.js +121 -0
- package/dist/core/path-utils.js.map +1 -0
- package/dist/core/path.d.ts +148 -0
- package/dist/core/path.d.ts.map +1 -0
- package/dist/core/path.js +674 -0
- package/dist/core/path.js.map +1 -0
- package/dist/core/primitives.d.ts +23 -0
- package/dist/core/primitives.d.ts.map +1 -0
- package/dist/core/primitives.js +54 -0
- package/dist/core/primitives.js.map +1 -0
- package/dist/core/read.d.ts +74 -0
- package/dist/core/read.d.ts.map +1 -0
- package/dist/core/read.js +562 -0
- package/dist/core/read.js.map +1 -0
- package/dist/core/schema.d.ts +139 -0
- package/dist/core/schema.d.ts.map +1 -0
- package/dist/core/schema.js +345 -0
- package/dist/core/schema.js.map +1 -0
- package/dist/core/search.d.ts +100 -0
- package/dist/core/search.d.ts.map +1 -0
- package/dist/core/search.js +248 -0
- package/dist/core/search.js.map +1 -0
- package/dist/core/sensitive.d.ts +6 -0
- package/dist/core/sensitive.d.ts.map +1 -0
- package/dist/core/sensitive.js +142 -0
- package/dist/core/sensitive.js.map +1 -0
- package/dist/core/store.d.ts +57 -0
- package/dist/core/store.d.ts.map +1 -0
- package/dist/core/store.js +162 -0
- package/dist/core/store.js.map +1 -0
- package/dist/core/util.d.ts +26 -0
- package/dist/core/util.d.ts.map +1 -0
- package/dist/core/util.js +66 -0
- package/dist/core/util.js.map +1 -0
- package/dist/core/watcher-registry.d.ts +68 -0
- package/dist/core/watcher-registry.d.ts.map +1 -0
- package/dist/core/watcher-registry.js +312 -0
- package/dist/core/watcher-registry.js.map +1 -0
- package/dist/http-policy.d.ts +121 -0
- package/dist/http-policy.d.ts.map +1 -0
- package/dist/http-policy.js +340 -0
- package/dist/http-policy.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +77 -41
- package/dist/index.js.map +1 -0
- package/dist/instructions.d.ts +12 -0
- package/dist/instructions.d.ts.map +1 -0
- package/dist/instructions.js +71 -0
- package/dist/instructions.js.map +1 -0
- package/dist/prompts.d.ts +8 -6
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +74 -168
- package/dist/prompts.js.map +1 -0
- package/dist/resources.d.ts +73 -9
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +392 -163
- package/dist/resources.js.map +1 -0
- package/dist/server.d.ts +62 -1
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +139 -1
- package/dist/server.js.map +1 -0
- package/dist/tools/batch.d.ts +89 -0
- package/dist/tools/batch.d.ts.map +1 -0
- package/dist/tools/batch.js +157 -0
- package/dist/tools/batch.js.map +1 -0
- package/dist/tools/create.d.ts +2 -0
- package/dist/tools/create.d.ts.map +1 -0
- package/dist/tools/create.js +142 -0
- package/dist/tools/create.js.map +1 -0
- package/dist/tools/define.d.ts +110 -0
- package/dist/tools/define.d.ts.map +1 -0
- package/dist/tools/define.js +394 -0
- package/dist/tools/define.js.map +1 -0
- package/dist/tools/delete-file.d.ts +2 -4
- package/dist/tools/delete-file.d.ts.map +1 -0
- package/dist/tools/delete-file.js +330 -87
- package/dist/tools/delete-file.js.map +1 -0
- package/dist/tools/diff.d.ts +2 -0
- package/dist/tools/diff.d.ts.map +1 -0
- package/dist/tools/diff.js +94 -0
- package/dist/tools/diff.js.map +1 -0
- package/dist/tools/edit.d.ts +2 -0
- package/dist/tools/edit.d.ts.map +1 -0
- package/dist/tools/edit.js +442 -0
- package/dist/tools/edit.js.map +1 -0
- package/dist/tools/index.d.ts +26 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +52 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/list.d.ts +2 -0
- package/dist/tools/list.d.ts.map +1 -0
- package/dist/tools/list.js +291 -0
- package/dist/tools/list.js.map +1 -0
- package/dist/tools/move.d.ts +2 -0
- package/dist/tools/move.d.ts.map +1 -0
- package/dist/tools/move.js +321 -0
- package/dist/tools/move.js.map +1 -0
- package/dist/tools/patch.d.ts +2 -0
- package/dist/tools/patch.d.ts.map +1 -0
- package/dist/tools/patch.js +155 -0
- package/dist/tools/patch.js.map +1 -0
- package/dist/tools/progress.d.ts +52 -0
- package/dist/tools/progress.d.ts.map +1 -0
- package/dist/tools/progress.js +172 -0
- package/dist/tools/progress.js.map +1 -0
- package/dist/tools/read.d.ts +2 -4
- package/dist/tools/read.d.ts.map +1 -0
- package/dist/tools/read.js +398 -152
- package/dist/tools/read.js.map +1 -0
- package/dist/tools/replace-in-files.d.ts +2 -4
- package/dist/tools/replace-in-files.d.ts.map +1 -0
- package/dist/tools/replace-in-files.js +435 -264
- package/dist/tools/replace-in-files.js.map +1 -0
- package/dist/tools/roots.d.ts +2 -4
- package/dist/tools/roots.d.ts.map +1 -0
- package/dist/tools/roots.js +29 -52
- package/dist/tools/roots.js.map +1 -0
- package/dist/tools/search-content.d.ts +2 -4
- package/dist/tools/search-content.d.ts.map +1 -0
- package/dist/tools/search-content.js +262 -228
- package/dist/tools/search-content.js.map +1 -0
- package/dist/tools/search-files.d.ts +2 -4
- package/dist/tools/search-files.d.ts.map +1 -0
- package/dist/tools/search-files.js +162 -161
- package/dist/tools/search-files.js.map +1 -0
- package/dist/tools/stat.d.ts +2 -4
- package/dist/tools/stat.d.ts.map +1 -0
- package/dist/tools/stat.js +202 -62
- package/dist/tools/stat.js.map +1 -0
- package/dist/transport/http.d.ts +5 -0
- package/dist/transport/http.d.ts.map +1 -0
- package/dist/transport/http.js +276 -0
- package/dist/transport/http.js.map +1 -0
- package/dist/transport/shared.d.ts +45 -0
- package/dist/transport/shared.d.ts.map +1 -0
- package/dist/transport/shared.js +65 -0
- package/dist/transport/shared.js.map +1 -0
- package/dist/transport/stdio.d.ts +32 -0
- package/dist/transport/stdio.d.ts.map +1 -0
- package/dist/transport/stdio.js +279 -0
- package/dist/transport/stdio.js.map +1 -0
- package/dist/transport.d.ts +5 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +4 -0
- package/dist/transport.js.map +1 -0
- package/package.json +37 -46
- package/dist/assets/logo.svg +0 -35
- package/dist/completions.d.ts +0 -2
- package/dist/completions.js +0 -572
- package/dist/config.d.ts +0 -119
- package/dist/config.js +0 -31
- package/dist/lib/abort.d.ts +0 -7
- package/dist/lib/abort.js +0 -81
- package/dist/lib/constants.d.ts +0 -42
- package/dist/lib/constants.js +0 -313
- package/dist/lib/errors.d.ts +0 -28
- package/dist/lib/errors.js +0 -301
- package/dist/lib/file-operations/core.d.ts +0 -53
- package/dist/lib/file-operations/core.js +0 -144
- package/dist/lib/file-operations/metadata.d.ts +0 -77
- package/dist/lib/file-operations/metadata.js +0 -878
- package/dist/lib/file-operations/search.d.ts +0 -46
- package/dist/lib/file-operations/search.js +0 -1194
- package/dist/lib/file-operations/traversal.d.ts +0 -40
- package/dist/lib/file-operations/traversal.js +0 -310
- package/dist/lib/fs-helpers.d.ts +0 -46
- package/dist/lib/fs-helpers.js +0 -606
- package/dist/lib/globs.d.ts +0 -2
- package/dist/lib/globs.js +0 -19
- package/dist/lib/logger.d.ts +0 -27
- package/dist/lib/logger.js +0 -91
- package/dist/lib/observability.d.ts +0 -33
- package/dist/lib/observability.js +0 -373
- package/dist/lib/paths.d.ts +0 -35
- package/dist/lib/paths.js +0 -634
- package/dist/lib/resource-store.d.ts +0 -28
- package/dist/lib/resource-store.js +0 -195
- package/dist/lib/utils.d.ts +0 -7
- package/dist/lib/utils.js +0 -37
- package/dist/lib/zod-codecs.d.ts +0 -2
- package/dist/lib/zod-codecs.js +0 -18
- package/dist/pkg-info.d.ts +0 -7
- package/dist/pkg-info.js +0 -9
- package/dist/resources/generated-instructions.d.ts +0 -1
- package/dist/resources/generated-instructions.js +0 -105
- package/dist/resources/tool-catalog.d.ts +0 -2
- package/dist/resources/tool-catalog.js +0 -78
- package/dist/resources/tool-info.d.ts +0 -9
- package/dist/resources/tool-info.js +0 -206
- package/dist/resources/workflows.d.ts +0 -1
- package/dist/resources/workflows.js +0 -72
- package/dist/schemas.d.ts +0 -505
- package/dist/schemas.js +0 -676
- package/dist/server/bootstrap.d.ts +0 -6
- package/dist/server/bootstrap.js +0 -563
- package/dist/server/event-store.d.ts +0 -18
- package/dist/server/event-store.js +0 -71
- package/dist/server/roots-manager.d.ts +0 -28
- package/dist/server/roots-manager.js +0 -227
- package/dist/server/task-store.d.ts +0 -10
- package/dist/server/task-store.js +0 -91
- package/dist/tools/apply-patch.d.ts +0 -4
- package/dist/tools/apply-patch.js +0 -235
- package/dist/tools/calculate-hash.d.ts +0 -4
- package/dist/tools/calculate-hash.js +0 -187
- package/dist/tools/contract.d.ts +0 -50
- package/dist/tools/contract.js +0 -1
- package/dist/tools/create-directory.d.ts +0 -4
- package/dist/tools/create-directory.js +0 -68
- package/dist/tools/diff-files.d.ts +0 -4
- package/dist/tools/diff-files.js +0 -136
- package/dist/tools/edit-file.d.ts +0 -4
- package/dist/tools/edit-file.js +0 -256
- package/dist/tools/icons.d.ts +0 -15
- package/dist/tools/icons.js +0 -24
- package/dist/tools/list-directory.d.ts +0 -4
- package/dist/tools/list-directory.js +0 -218
- package/dist/tools/move-file.d.ts +0 -4
- package/dist/tools/move-file.js +0 -178
- package/dist/tools/read-multiple.d.ts +0 -4
- package/dist/tools/read-multiple.js +0 -207
- package/dist/tools/shared.d.ts +0 -172
- package/dist/tools/shared.js +0 -599
- package/dist/tools/stat-many.d.ts +0 -4
- package/dist/tools/stat-many.js +0 -104
- package/dist/tools/task-support.d.ts +0 -29
- package/dist/tools/task-support.js +0 -472
- package/dist/tools/tree.d.ts +0 -4
- package/dist/tools/tree.js +0 -102
- package/dist/tools/write-file.d.ts +0 -4
- package/dist/tools/write-file.js +0 -60
- package/dist/tools.d.ts +0 -5
- package/dist/tools.js +0 -54
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/transport/http.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,6EAA6E;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAM3D,OAAO,EACL,gBAAgB,EAChB,4BAA4B,EAC5B,iBAAiB,GAClB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAI7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EACL,qBAAqB,EACrB,YAAY,GAEb,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,IAAI,EAAE,CAAC,CAAC;YACrE,OAAO,CAAC,UAAU,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// HTTP hosting: express app assembly, security middleware wiring, the modern\n// per-request server factory, and listen-filter watcher gating on POST /mcp.\nimport { createMcpExpressApp } from '@modelcontextprotocol/express';\nimport { toNodeHandler } from '@modelcontextprotocol/node';\nimport type {\n McpHttpHandler,\n McpServerFactory,\n ServerNotifier,\n} from '@modelcontextprotocol/server';\nimport {\n createMcpHandler,\n DEFAULT_REQUEST_TIMEOUT_MSEC,\n ProtocolErrorCode,\n} from '@modelcontextprotocol/server';\n\nimport type { Server } from 'node:http';\nimport { createServer as createHttpServer } from 'node:http';\n\nimport type { Express, NextFunction, Request, Response } from 'express';\n\nimport { formatUnknownErrorMessage } from '../core/errors.js';\nimport { assertFleetRequestStateKey } from '../core/input-required.js';\nimport { Logger } from '../core/observability.js';\nimport { PageSnapshotStore } from '../core/page-store.js';\nimport { PathGuard } from '../core/path.js';\nimport type { ServerOptions } from '../core/path.js';\nimport { parseTrueEnvFlag } from '../core/primitives.js';\nimport { ResourceStore } from '../core/store.js';\nimport { MIB, parseEnvInt } from '../core/util.js';\nimport {\n createWatcherRegistry,\n MAX_WATCHERS,\n type WatcherRegistry,\n} from '../core/watcher-registry.js';\nimport {\n assertHttpBindingPolicy,\n assertHttpHostPolicy,\n bearerAuthMiddleware,\n computeAllowedOriginHostnames,\n corsOriginMiddleware,\n corsPreflightHandler,\n createRateLimiter,\n protectedResourceUrl,\n resolveAllowedHosts,\n resolveTrustProxySetting,\n sendJsonRpcError,\n} from '../http-policy.js';\nimport { createServer } from '../server.js';\nimport type { RuntimeConfig } from './shared.js';\nimport {\n isStructurallyValidListen,\n jsonRpcRequestId,\n listenSubscriptionUris,\n prepareListenWatchers,\n} from './shared.js';\n\nconst MAX_REQUEST_BODY_BYTES = parseEnvInt('FS_MAX_REQUEST_BYTES', 4 * MIB, 1024, 256 * MIB);\n\n/**\n * The code the SDK's own non-POST rejection carries. Not a `ProtocolErrorCode`\n * member — the enum has no `-32000` — so it is pinned here to keep the local\n * 405 envelope identical to the one the handler would have produced.\n */\nconst SDK_METHOD_NOT_ALLOWED_CODE = -32000;\n\n/** Body-parser rejections and anything else that reaches the end of the chain. */\nfunction errorHandlerMiddleware(\n err: Error & { status?: number },\n _req: Request,\n res: Response,\n next: NextFunction,\n): void {\n if (res.headersSent) {\n next(err);\n return;\n }\n if (err.status === 413) {\n sendJsonRpcError(res, 413, ProtocolErrorCode.InvalidRequest, 'Request body too large');\n return;\n }\n if (err.status === 400) {\n sendJsonRpcError(res, 400, ProtocolErrorCode.ParseError, 'Invalid JSON in request body');\n return;\n }\n Logger.error('[HTTP] Unhandled middleware error:', formatUnknownErrorMessage(err));\n sendJsonRpcError(res, 500, ProtocolErrorCode.InternalError, 'Internal Server Error');\n}\n\nfunction makeHttpModernFactory(\n options: ServerOptions,\n getNotifier: () => ServerNotifier,\n sharedRegistry: WatcherRegistry,\n sharedPathGuard: PathGuard,\n sharedStore: ResourceStore,\n sharedPageStore: PageSnapshotStore,\n apiKey: string | undefined,\n): McpServerFactory {\n return async ({ era }) => {\n const notifier = getNotifier();\n const c = await createServer(options, {\n watcherRegistry: sharedRegistry,\n notifier,\n pathGuard: sharedPathGuard,\n resourceStore: sharedStore,\n pageStore: sharedPageStore,\n era,\n ...(apiKey !== undefined ? { apiKey } : {}),\n });\n const previousOnClose = c.mcp.server.onclose;\n c.mcp.server.onclose = () => {\n previousOnClose?.();\n c.disposeRuntimeState();\n };\n return c.mcp;\n };\n}\n\nfunction setupExpressApp(\n httpHost: string,\n apiKey: string | undefined,\n allowedHosts: string[],\n modernNodeHandler: (req: Request, res: Response, parsedBody?: unknown) => Promise<void>,\n sharedPathGuard: PathGuard,\n sharedRegistry: WatcherRegistry,\n notifier: ServerNotifier,\n): Express {\n const allowedOriginHostnames = computeAllowedOriginHostnames(process.env['FS_ALLOWED_ORIGINS']);\n // Read once here and passed down, like every other env-derived policy input:\n // http-policy holds no state and reads no env of its own.\n const publicUrl = process.env['FS_PUBLIC_URL'];\n\n const app = createMcpExpressApp({\n host: httpHost,\n jsonLimit: `${MAX_REQUEST_BODY_BYTES}b`,\n ...(allowedHosts.length > 0 ? { allowedHosts: [...allowedHosts] } : {}),\n ...(allowedOriginHostnames.length > 0 ? { allowedOrigins: [...allowedOriginHostnames] } : {}),\n });\n\n const trustProxy = resolveTrustProxySetting(process.env['FS_TRUST_PROXY']);\n if (trustProxy !== undefined) {\n app.set('trust proxy', trustProxy);\n }\n\n if (allowedHosts.length === 0) {\n Logger.warn(\n '[HTTP] FS_ALLOW_UNRESTRICTED_HOSTS is set: binding globally without Host validation.',\n );\n }\n\n app.options('/mcp', corsPreflightHandler(allowedOriginHostnames));\n app.use('/mcp', corsOriginMiddleware(allowedOriginHostnames));\n\n // Unconditional: the spec's rate-limit MUST is not scoped to authenticated\n // binds. A keyless bind is loopback-only, so the cap is looser, not absent.\n const rpm = parseEnvInt('FS_RATE_LIMIT_RPM', apiKey ? 120 : 6_000, 1, 100_000);\n app.use('/mcp', createRateLimiter(rpm));\n\n if (apiKey && allowedHosts.length > 0) {\n const metadataHandler = (req: Request, res: Response): void => {\n const resource = protectedResourceUrl(req, true, publicUrl);\n if (!resource) {\n // Unreachable for the unrestricted case (the gate above excludes it),\n // but defend a FS_PUBLIC_URL parse failure with a bodyless\n // 404 — a generic OAuth client cannot parse a JSON-RPC error envelope.\n res.status(404).end();\n return;\n }\n res.header('Access-Control-Allow-Origin', '*');\n res.status(200).json({\n resource: resource.href,\n bearer_methods_supported: ['header'],\n resource_name: 'filesystem-mcp',\n });\n };\n app.get(\n ['/.well-known/oauth-protected-resource', '/.well-known/oauth-protected-resource/mcp'],\n metadataHandler,\n );\n }\n\n app.get('/healthz', (_req: Request, res: Response) => {\n res.status(200).json({\n status: 'ok',\n uptime: process.uptime(),\n });\n });\n\n app.use('/mcp', bearerAuthMiddleware(apiKey, allowedHosts.length > 0, publicUrl));\n\n const resourceUpdateSink = (uri: string): void => {\n notifier.resourceUpdated(uri);\n };\n\n app.post('/mcp', (req: Request, res: Response, next: NextFunction) => {\n void (async () => {\n const parsedBody = req.body as unknown;\n // Only a structurally valid listen gets watchers, mirroring the stdio\n // gate. A malformed one cannot succeed downstream, so attaching handles\n // for it only gives the response-close release something to undo — and\n // everything that is not a listen takes no watchers either way.\n if (!isStructurallyValidListen(parsedBody)) {\n await modernNodeHandler(req, res, parsedBody);\n return;\n }\n\n // Reject an over-cap listen before the ack so the client does not believe\n // every requested URI is watched when the watcher budget is exhausted.\n // The per-URI `capped` failure below would also reject, but only after\n // creating and tearing down every watcher up to the cap.\n const requestedUris = listenSubscriptionUris(parsedBody);\n // Only URIs without a live watcher consume a slot; a re-listen to an\n // already-watched URI just retains another lease.\n const newUris = requestedUris.filter((uri) => !sharedRegistry.hasWatcher(uri));\n const available = MAX_WATCHERS - sharedRegistry.size();\n if (newUris.length > available) {\n sendJsonRpcError(\n res,\n 400,\n ProtocolErrorCode.InvalidParams,\n `subscriptions/listen names ${newUris.length} not-yet-watched URIs but only ${available} watcher slots remain (cap ${MAX_WATCHERS}). Reduce the resourceSubscriptions list.`,\n jsonRpcRequestId(parsedBody),\n );\n return;\n }\n\n const prepared = await prepareListenWatchers(\n parsedBody,\n sharedPathGuard,\n sharedRegistry,\n resourceUpdateSink,\n );\n if (!prepared.ok) {\n sendJsonRpcError(\n res,\n 400,\n ProtocolErrorCode.InvalidParams,\n prepared.message,\n jsonRpcRequestId(parsedBody),\n );\n return;\n }\n\n let released = false;\n const release = (): void => {\n if (released) return;\n released = true;\n for (const uri of prepared.acquiredUris) sharedRegistry.release(uri);\n };\n if (prepared.acquiredUris.length > 0) {\n // The attach loop awaits per-URI path validation, so the client can be\n // gone by the time it returns. `close` fires once: a listener attached\n // after it would never run and every lease this batch took would leak\n // until process shutdown.\n if (res.closed || res.destroyed || res.writableEnded) release();\n else res.once('close', release);\n }\n\n try {\n await modernNodeHandler(req, res, parsedBody);\n } catch (error) {\n release();\n throw error;\n }\n })().catch(next);\n });\n\n // Answer non-POST here rather than handing it to `modernNodeHandler`. The\n // SDK's own 405 is byte-identical to this one, but it omits the `Allow`\n // header RFC 9110 §15.5.6 requires and routes every routine GET probe through\n // the handler's `onerror` — which this server logs at error level.\n app.all('/mcp', (_req: Request, res: Response) => {\n sendJsonRpcError(res, 405, SDK_METHOD_NOT_ALLOWED_CODE, 'Method not allowed.', null, {\n Allow: 'POST, OPTIONS',\n });\n });\n\n app.use(errorHandlerMiddleware);\n\n return app;\n}\n\nexport async function startHttpServer(\n port: number,\n options: ServerOptions,\n config: RuntimeConfig = {},\n): Promise<Server> {\n const httpHost = config.httpHost ?? '127.0.0.1';\n const { apiKey, eventBus } = config;\n const fleet = config.deploymentMode === 'fleet';\n assertHttpBindingPolicy(httpHost, apiKey);\n if (fleet && !apiKey) {\n throw new Error('Fleet deployment mode requires an API key.');\n }\n if (fleet && !eventBus) {\n throw new Error('Fleet deployment mode requires a shared event bus.');\n }\n assertFleetRequestStateKey(fleet);\n const allowedHosts = resolveAllowedHosts(httpHost, process.env['FS_ALLOWED_HOSTS']);\n assertHttpHostPolicy(\n httpHost,\n allowedHosts,\n parseTrueEnvFlag(process.env['FS_ALLOW_UNRESTRICTED_HOSTS'], 'FS_ALLOW_UNRESTRICTED_HOSTS'),\n );\n\n const sharedRegistry = createWatcherRegistry();\n // One store for the whole endpoint, same lifetime and same one-credential\n // trust argument as the shared guard below: a result a tool externalized in\n // one POST must survive to the follow-up resources/read, and the modern leg\n // builds a fresh McpServer per request so a per-request store would discard\n // it immediately.\n // Fires only from a tool call, which is long after `modernHandler` below is\n // constructed, so reading it from the closure is safe (same as `getNotifier`).\n const sharedStore = new ResourceStore(() => {\n modernHandler.notify.resourcesChanged();\n });\n const sharedPageStore = new PageSnapshotStore();\n // One guard for the whole endpoint. The modern leg builds a fresh McpServer\n // per request, so a per-instance guard would discard every accepted access\n // grant the moment the request ended — re-prompting on each subsequent call\n // and leaving the listen-watcher path validating against a stale allowed set.\n // Grant scope is therefore the endpoint, not the connection: with API_KEY set\n // every caller presents the same key (one auth context by construction), and\n // without it the bind is loopback-only. Split into per-auth-context guards if\n // this ever serves more than one credential.\n const sharedPathGuard = new PathGuard(options, true);\n await sharedPathGuard.recomputeAllowedDirectories();\n\n const modernHandler: McpHttpHandler = createMcpHandler(\n makeHttpModernFactory(\n options,\n () => modernHandler.notify,\n sharedRegistry,\n sharedPathGuard,\n sharedStore,\n sharedPageStore,\n apiKey,\n ),\n {\n legacy: 'reject',\n ...(eventBus ? { bus: eventBus } : {}),\n onerror: (error: Error) => {\n Logger.error('[HTTP] modern leg error:', formatUnknownErrorMessage(error));\n },\n },\n );\n const modernNodeHandler = toNodeHandler(modernHandler);\n\n const app = setupExpressApp(\n httpHost,\n apiKey,\n allowedHosts,\n modernNodeHandler,\n sharedPathGuard,\n sharedRegistry,\n modernHandler.notify,\n );\n\n const httpServer = createHttpServer(app);\n // Must exceed the idle timeout of any proxy in front of this server, or the\n // proxy reuses connections the server already closed (intermittent 502s).\n const keepAliveMs = parseEnvInt('FS_KEEPALIVE_TIMEOUT_MS', 5_000, 1_000, 600_000);\n httpServer.keepAliveTimeout = keepAliveMs;\n httpServer.headersTimeout = keepAliveMs + 5_000;\n httpServer.requestTimeout = DEFAULT_REQUEST_TIMEOUT_MSEC;\n\n const onHttpServerError = (error: Error): void => {\n Logger.error('[HTTP] runtime server error', {\n host: httpHost,\n port,\n error: formatUnknownErrorMessage(error),\n });\n };\n httpServer.on('error', onHttpServerError);\n\n const originalClose = httpServer.close.bind(httpServer);\n httpServer.close = function (callback?: (error?: Error) => void) {\n sharedRegistry.destroy();\n sharedPageStore.clear();\n modernHandler\n .close()\n .then(() => {\n originalClose(callback);\n })\n .catch((err: unknown) => {\n Logger.error(\n '[HTTP] Error closing handler during HTTP server close:',\n formatUnknownErrorMessage(err),\n );\n originalClose(callback);\n });\n return httpServer;\n };\n\n return new Promise((resolve, reject) => {\n const onError = (err: Error) => {\n sharedRegistry.destroy();\n sharedPageStore.clear();\n modernHandler.close().catch((closeErr: unknown) => {\n Logger.error(\n '[HTTP] Error closing handler on startup failure:',\n formatUnknownErrorMessage(closeErr),\n );\n });\n reject(err);\n };\n httpServer.once('error', onError);\n\n httpServer.listen(port, httpHost, () => {\n httpServer.removeListener('error', onError);\n Logger.info(`[HTTP] Server listening on http://${httpHost}:${port}`);\n resolve(httpServer);\n });\n });\n}\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ServerEventBus } from '@modelcontextprotocol/server';
|
|
2
|
+
import type { PathGuard } from '../core/path.js';
|
|
3
|
+
import { type WatcherRegistry } from '../core/watcher-registry.js';
|
|
4
|
+
/**
|
|
5
|
+
* Runtime inputs the CLI resolves once (flag, else the operator's env var) and
|
|
6
|
+
* hands the transport. Separate from `ServerOptions` because that object is
|
|
7
|
+
* `PathGuard`'s constructor argument: the filesystem guard has no use for a
|
|
8
|
+
* bind address and no business holding a bearer secret.
|
|
9
|
+
*/
|
|
10
|
+
export interface RuntimeConfig {
|
|
11
|
+
/** `--http-host` or `HTTP_HOST`. The HTTP bind defaults to loopback without it. */
|
|
12
|
+
httpHost?: string;
|
|
13
|
+
/** `--api-key` or `API_KEY`. Unset means open access (loopback dev mode). */
|
|
14
|
+
apiKey?: string;
|
|
15
|
+
/** Shared change-event bus for multi-instance HTTP deployments. Caller-owned. */
|
|
16
|
+
eventBus?: ServerEventBus;
|
|
17
|
+
/** Explicit topology; fleet mode requires shared state and event delivery. */
|
|
18
|
+
deploymentMode?: 'single' | 'fleet';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* True when `message` really is a `subscriptions/listen` request, not merely a
|
|
22
|
+
* body carrying that method string. Both legs gate watcher attachment on this:
|
|
23
|
+
* a malformed listen cannot succeed downstream, so creating and tearing down
|
|
24
|
+
* `fs.watch` handles for it is pure waste — and on HTTP the teardown depended on
|
|
25
|
+
* the response-close listener firing. Non-listen bodies fail it too, which is
|
|
26
|
+
* the same answer `listenSubscriptionUris` gives them.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isStructurallyValidListen(message: unknown): boolean;
|
|
29
|
+
/** The request id of a parsed JSON-RPC body, for error-envelope echo. */
|
|
30
|
+
export declare function jsonRpcRequestId(parsedBody: unknown): string | number | null;
|
|
31
|
+
/** The `resourceSubscriptions` URIs of a `subscriptions/listen` body, de-duplicated. */
|
|
32
|
+
export declare function listenSubscriptionUris(parsedBody: unknown): string[];
|
|
33
|
+
export type ListenPreparation = {
|
|
34
|
+
readonly ok: true;
|
|
35
|
+
readonly acquiredUris: string[];
|
|
36
|
+
} | {
|
|
37
|
+
readonly ok: false;
|
|
38
|
+
readonly message: string;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Prepare every filesystem watcher named by a `subscriptions/listen` filter.
|
|
42
|
+
* The batch is all-or-nothing: a failed URI releases each prior lease.
|
|
43
|
+
*/
|
|
44
|
+
export declare function prepareListenWatchers(parsedBody: unknown, pathGuard: PathGuard, registry: WatcherRegistry, notify: (uri: string) => void): Promise<ListenPreparation>;
|
|
45
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/transport/shared.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAInE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,6BAA6B,CAAC;AAErC;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,mFAAmF;IACnF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iFAAiF;IACjF,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,8EAA8E;IAC9E,cAAc,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;CACrC;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAGnE;AAED,yEAAyE;AACzE,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAG5E;AAED,wFAAwF;AACxF,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,OAAO,GAAG,MAAM,EAAE,CAYpE;AAED,MAAM,MAAM,iBAAiB,GACzB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,CAAA;CAAE,GACtD;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAoBrD;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,UAAU,EAAE,OAAO,EACnB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,eAAe,EACzB,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAC5B,OAAO,CAAC,iBAAiB,CAAC,CAY5B"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { specTypeSchemas } from '@modelcontextprotocol/server';
|
|
2
|
+
import { formatUnknownErrorMessage } from '../core/errors.js';
|
|
3
|
+
import { MAX_WATCHERS, } from '../core/watcher-registry.js';
|
|
4
|
+
/**
|
|
5
|
+
* True when `message` really is a `subscriptions/listen` request, not merely a
|
|
6
|
+
* body carrying that method string. Both legs gate watcher attachment on this:
|
|
7
|
+
* a malformed listen cannot succeed downstream, so creating and tearing down
|
|
8
|
+
* `fs.watch` handles for it is pure waste — and on HTTP the teardown depended on
|
|
9
|
+
* the response-close listener firing. Non-listen bodies fail it too, which is
|
|
10
|
+
* the same answer `listenSubscriptionUris` gives them.
|
|
11
|
+
*/
|
|
12
|
+
export function isStructurallyValidListen(message) {
|
|
13
|
+
const result = specTypeSchemas.SubscriptionsListenRequest['~standard'].validate(message);
|
|
14
|
+
return !('issues' in result);
|
|
15
|
+
}
|
|
16
|
+
/** The request id of a parsed JSON-RPC body, for error-envelope echo. */
|
|
17
|
+
export function jsonRpcRequestId(parsedBody) {
|
|
18
|
+
const id = parsedBody?.id;
|
|
19
|
+
return typeof id === 'string' || typeof id === 'number' ? id : null;
|
|
20
|
+
}
|
|
21
|
+
/** The `resourceSubscriptions` URIs of a `subscriptions/listen` body, de-duplicated. */
|
|
22
|
+
export function listenSubscriptionUris(parsedBody) {
|
|
23
|
+
if (typeof parsedBody !== 'object' || parsedBody === null)
|
|
24
|
+
return [];
|
|
25
|
+
const body = parsedBody;
|
|
26
|
+
if (body.method !== 'subscriptions/listen')
|
|
27
|
+
return [];
|
|
28
|
+
const uris = body.params?.notifications?.resourceSubscriptions;
|
|
29
|
+
if (!Array.isArray(uris))
|
|
30
|
+
return [];
|
|
31
|
+
// De-duplicate: one attach must yield one ref-count, or the release below
|
|
32
|
+
// decrements further than it incremented and tears down a live watcher.
|
|
33
|
+
return [...new Set(uris.filter((uri) => typeof uri === 'string'))];
|
|
34
|
+
}
|
|
35
|
+
const WATCHER_FAILURE_REASONS = {
|
|
36
|
+
'bad-uri': 'unsupported resource URI',
|
|
37
|
+
capped: `watcher limit ${MAX_WATCHERS} reached`,
|
|
38
|
+
'attach-failed': 'filesystem watcher could not be created',
|
|
39
|
+
stale: 'subscription was cancelled during setup',
|
|
40
|
+
};
|
|
41
|
+
function watcherFailureMessage(uri, result) {
|
|
42
|
+
const why = result.reason === 'invalid-path'
|
|
43
|
+
? formatUnknownErrorMessage(result.error)
|
|
44
|
+
: WATCHER_FAILURE_REASONS[result.reason];
|
|
45
|
+
return `Cannot subscribe to ${uri}: ${why}`;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Prepare every filesystem watcher named by a `subscriptions/listen` filter.
|
|
49
|
+
* The batch is all-or-nothing: a failed URI releases each prior lease.
|
|
50
|
+
*/
|
|
51
|
+
export async function prepareListenWatchers(parsedBody, pathGuard, registry, notify) {
|
|
52
|
+
const uris = listenSubscriptionUris(parsedBody);
|
|
53
|
+
const acquired = [];
|
|
54
|
+
for (const uri of uris) {
|
|
55
|
+
const result = await registry.acquire(pathGuard, uri, notify);
|
|
56
|
+
if (!result.ok) {
|
|
57
|
+
for (const prior of acquired)
|
|
58
|
+
registry.release(prior);
|
|
59
|
+
return { ok: false, message: watcherFailureMessage(uri, result) };
|
|
60
|
+
}
|
|
61
|
+
acquired.push(uri);
|
|
62
|
+
}
|
|
63
|
+
return { ok: true, acquiredUris: acquired };
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/transport/shared.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,EACL,YAAY,GAGb,MAAM,6BAA6B,CAAC;AAmBrC;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CAAC,OAAgB;IACxD,MAAM,MAAM,GAAG,eAAe,CAAC,0BAA0B,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACzF,OAAO,CAAC,CAAC,QAAQ,IAAI,MAAM,CAAC,CAAC;AAC/B,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,gBAAgB,CAAC,UAAmB;IAClD,MAAM,EAAE,GAAI,UAAkD,EAAE,EAAE,CAAC;IACnE,OAAO,OAAO,EAAE,KAAK,QAAQ,IAAI,OAAO,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACtE,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,sBAAsB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,CAAC;QACvB,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QAC9D,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;YACf,KAAK,MAAM,KAAK,IAAI,QAAQ;gBAAE,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACtD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,qBAAqB,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,CAAC;QACpE,CAAC;QACD,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC;AAC9C,CAAC","sourcesContent":["// Pieces both transport legs share: the runtime config contract and the\n// `subscriptions/listen` watcher-preparation ladder. stdio and HTTP gate the\n// same message shape; only where the lease is released differs (connection\n// close vs response close).\nimport type { ServerEventBus } from '@modelcontextprotocol/server';\nimport { specTypeSchemas } from '@modelcontextprotocol/server';\n\nimport { formatUnknownErrorMessage } from '../core/errors.js';\nimport type { PathGuard } from '../core/path.js';\nimport {\n MAX_WATCHERS,\n type WatcherAttachResult,\n type WatcherRegistry,\n} from '../core/watcher-registry.js';\n\n/**\n * Runtime inputs the CLI resolves once (flag, else the operator's env var) and\n * hands the transport. Separate from `ServerOptions` because that object is\n * `PathGuard`'s constructor argument: the filesystem guard has no use for a\n * bind address and no business holding a bearer secret.\n */\nexport interface RuntimeConfig {\n /** `--http-host` or `HTTP_HOST`. The HTTP bind defaults to loopback without it. */\n httpHost?: string;\n /** `--api-key` or `API_KEY`. Unset means open access (loopback dev mode). */\n apiKey?: string;\n /** Shared change-event bus for multi-instance HTTP deployments. Caller-owned. */\n eventBus?: ServerEventBus;\n /** Explicit topology; fleet mode requires shared state and event delivery. */\n deploymentMode?: 'single' | 'fleet';\n}\n\n/**\n * True when `message` really is a `subscriptions/listen` request, not merely a\n * body carrying that method string. Both legs gate watcher attachment on this:\n * a malformed listen cannot succeed downstream, so creating and tearing down\n * `fs.watch` handles for it is pure waste — and on HTTP the teardown depended on\n * the response-close listener firing. Non-listen bodies fail it too, which is\n * the same answer `listenSubscriptionUris` gives them.\n */\nexport function isStructurallyValidListen(message: unknown): boolean {\n const result = specTypeSchemas.SubscriptionsListenRequest['~standard'].validate(message);\n return !('issues' in result);\n}\n\n/** The request id of a parsed JSON-RPC body, for error-envelope echo. */\nexport function jsonRpcRequestId(parsedBody: unknown): string | number | null {\n const id = (parsedBody as { id?: unknown } | null | undefined)?.id;\n return typeof id === 'string' || typeof id === 'number' ? id : null;\n}\n\n/** The `resourceSubscriptions` URIs of a `subscriptions/listen` body, de-duplicated. */\nexport function listenSubscriptionUris(parsedBody: unknown): string[] {\n if (typeof parsedBody !== 'object' || parsedBody === null) return [];\n const body = parsedBody as {\n method?: unknown;\n params?: { notifications?: { resourceSubscriptions?: unknown } };\n };\n if (body.method !== 'subscriptions/listen') return [];\n const uris = body.params?.notifications?.resourceSubscriptions;\n if (!Array.isArray(uris)) return [];\n // De-duplicate: one attach must yield one ref-count, or the release below\n // decrements further than it incremented and tears down a live watcher.\n return [...new Set(uris.filter((uri): uri is string => typeof uri === 'string'))];\n}\n\nexport type ListenPreparation =\n | { readonly ok: true; readonly acquiredUris: string[] }\n | { readonly ok: false; readonly message: string };\n\nconst WATCHER_FAILURE_REASONS = {\n 'bad-uri': 'unsupported resource URI',\n capped: `watcher limit ${MAX_WATCHERS} reached`,\n 'attach-failed': 'filesystem watcher could not be created',\n stale: 'subscription was cancelled during setup',\n} as const;\n\nfunction watcherFailureMessage(\n uri: string,\n result: Exclude<WatcherAttachResult, { ok: true }>,\n): string {\n const why =\n result.reason === 'invalid-path'\n ? formatUnknownErrorMessage(result.error)\n : WATCHER_FAILURE_REASONS[result.reason];\n return `Cannot subscribe to ${uri}: ${why}`;\n}\n\n/**\n * Prepare every filesystem watcher named by a `subscriptions/listen` filter.\n * The batch is all-or-nothing: a failed URI releases each prior lease.\n */\nexport async function prepareListenWatchers(\n parsedBody: unknown,\n pathGuard: PathGuard,\n registry: WatcherRegistry,\n notify: (uri: string) => void,\n): Promise<ListenPreparation> {\n const uris = listenSubscriptionUris(parsedBody);\n const acquired: string[] = [];\n for (const uri of uris) {\n const result = await registry.acquire(pathGuard, uri, notify);\n if (!result.ok) {\n for (const prior of acquired) registry.release(prior);\n return { ok: false, message: watcherFailureMessage(uri, result) };\n }\n acquired.push(uri);\n }\n return { ok: true, acquiredUris: acquired };\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type StdioServerHandle } from '@modelcontextprotocol/server/stdio';
|
|
2
|
+
import type { ServerOptions } from '../core/path.js';
|
|
3
|
+
import type { FilesystemServerContext } from '../server.js';
|
|
4
|
+
import type { RuntimeConfig } from './shared.js';
|
|
5
|
+
/**
|
|
6
|
+
* Seed the guard's allowed roots from the client's declared workspace roots.
|
|
7
|
+
* Legacy-era only: push-style `roots/list` is deprecated (SEP-2577) and throws
|
|
8
|
+
* on a 2026-07-28 connection, where clients pass paths as tool arguments and
|
|
9
|
+
* the access-grant round-trip covers out-of-root paths instead. Every root
|
|
10
|
+
* still passes `applyGrant`'s boundary and unsafe-path guards, so a client
|
|
11
|
+
* cannot root-declare its way into $HOME or past FS_ROOT_BOUNDARY — a refused
|
|
12
|
+
* root is skipped and its paths fail closed at validateAccess like any other.
|
|
13
|
+
*/
|
|
14
|
+
export declare function seedRootsFromClient(ctx: FilesystemServerContext): Promise<number>;
|
|
15
|
+
/**
|
|
16
|
+
* Serve filesystem-mcp over stdio using modern protocol revision 2026-07-28.
|
|
17
|
+
*
|
|
18
|
+
* The SDK's `StdioListenRouter` acknowledges `subscriptions/listen` and routes
|
|
19
|
+
* the pinned instance's outbound change notifications onto the matching
|
|
20
|
+
* streams, but it exposes no listen-filter hook, so nothing attaches the
|
|
21
|
+
* filesystem watcher that would produce those notifications. `serveStdio`'s
|
|
22
|
+
* `transport` option is the seam: it installs its own `onmessage` synchronously
|
|
23
|
+
* and only then starts the wire, so wrapping that callback afterwards gives the
|
|
24
|
+
* same view of the inbound `resourceSubscriptions` filter the HTTP leg reads off
|
|
25
|
+
* `req.body`. The watcher's notify sink calls `sendResourceUpdated` on the
|
|
26
|
+
* pinned instance, which the router then delivers to the listening stream.
|
|
27
|
+
*
|
|
28
|
+
* Watcher leases are tracked by listen request ID and released on cancellation,
|
|
29
|
+
* rejection, graceful completion, or connection close.
|
|
30
|
+
*/
|
|
31
|
+
export declare function startServer(options: ServerOptions, config?: RuntimeConfig): StdioServerHandle;
|
|
32
|
+
//# sourceMappingURL=stdio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["../../src/transport/stdio.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,iBAAiB,EAEvB,MAAM,oCAAoC,CAAC;AAM5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAE5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAgCjD;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,CAqCvF;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,GAAE,aAAkB,GAAG,iBAAiB,CA+LjG"}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { JSONRPC_VERSION, ProtocolErrorCode } from '@modelcontextprotocol/server';
|
|
2
|
+
import { serveStdio, StdioServerTransport, } from '@modelcontextprotocol/server/stdio';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { formatUnknownErrorMessage } from '../core/errors.js';
|
|
5
|
+
import { Logger } from '../core/observability.js';
|
|
6
|
+
import { PathGuard } from '../core/path.js';
|
|
7
|
+
import { createWatcherRegistry } from '../core/watcher-registry.js';
|
|
8
|
+
import { createServer } from '../server.js';
|
|
9
|
+
import { isStructurallyValidListen, jsonRpcRequestId, listenSubscriptionUris, prepareListenWatchers, } from './shared.js';
|
|
10
|
+
// Read through a function, not `state.cancelled` directly: a cancellation lands
|
|
11
|
+
// between the checks, and control-flow narrowing from the first one would
|
|
12
|
+
// otherwise make the second read a compile-time constant.
|
|
13
|
+
function isListenCancelled(state) {
|
|
14
|
+
return state.cancelled;
|
|
15
|
+
}
|
|
16
|
+
function cancelledRequestId(message) {
|
|
17
|
+
if (typeof message !== 'object' || message === null)
|
|
18
|
+
return null;
|
|
19
|
+
const notification = message;
|
|
20
|
+
if (notification.method !== 'notifications/cancelled')
|
|
21
|
+
return null;
|
|
22
|
+
const requestId = notification.params?.requestId;
|
|
23
|
+
return typeof requestId === 'string' || typeof requestId === 'number' ? requestId : null;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Seed the guard's allowed roots from the client's declared workspace roots.
|
|
27
|
+
* Legacy-era only: push-style `roots/list` is deprecated (SEP-2577) and throws
|
|
28
|
+
* on a 2026-07-28 connection, where clients pass paths as tool arguments and
|
|
29
|
+
* the access-grant round-trip covers out-of-root paths instead. Every root
|
|
30
|
+
* still passes `applyGrant`'s boundary and unsafe-path guards, so a client
|
|
31
|
+
* cannot root-declare its way into $HOME or past FS_ROOT_BOUNDARY — a refused
|
|
32
|
+
* root is skipped and its paths fail closed at validateAccess like any other.
|
|
33
|
+
*/
|
|
34
|
+
export async function seedRootsFromClient(ctx) {
|
|
35
|
+
let roots;
|
|
36
|
+
try {
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- legacy-era-only; the modern era never reaches the hooks that call this.
|
|
38
|
+
({ roots } = await ctx.mcp.server.listRoots());
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
// Client without the roots capability (strict-capabilities throw), or the
|
|
42
|
+
// request failed — either way there is nothing to seed.
|
|
43
|
+
Logger.debug('[Stdio] roots/list unavailable', { error: formatUnknownErrorMessage(err) });
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
46
|
+
let granted = 0;
|
|
47
|
+
for (const root of roots) {
|
|
48
|
+
let dir;
|
|
49
|
+
try {
|
|
50
|
+
dir = fileURLToPath(root.uri);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
continue; // not a file:// root
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
if (await ctx.pathGuard.applyGrant(dir))
|
|
57
|
+
granted += 1;
|
|
58
|
+
else
|
|
59
|
+
Logger.debug('[Stdio] client root refused by grant policy', { dir });
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
Logger.debug('[Stdio] client root grant failed', {
|
|
63
|
+
dir,
|
|
64
|
+
error: formatUnknownErrorMessage(err),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// No list-changed notification follows a grant. Allowed roots were once listed
|
|
69
|
+
// as concrete resources, and are not any more: the file template's `list()`
|
|
70
|
+
// returns nothing and the other two lists never read the roots at all (see
|
|
71
|
+
// resources.ts). Notifying bought the client a re-fetch of an unchanged list.
|
|
72
|
+
if (granted > 0) {
|
|
73
|
+
Logger.info(`[Stdio] allowed ${granted} client-declared workspace root(s)`);
|
|
74
|
+
}
|
|
75
|
+
return granted;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Serve filesystem-mcp over stdio using modern protocol revision 2026-07-28.
|
|
79
|
+
*
|
|
80
|
+
* The SDK's `StdioListenRouter` acknowledges `subscriptions/listen` and routes
|
|
81
|
+
* the pinned instance's outbound change notifications onto the matching
|
|
82
|
+
* streams, but it exposes no listen-filter hook, so nothing attaches the
|
|
83
|
+
* filesystem watcher that would produce those notifications. `serveStdio`'s
|
|
84
|
+
* `transport` option is the seam: it installs its own `onmessage` synchronously
|
|
85
|
+
* and only then starts the wire, so wrapping that callback afterwards gives the
|
|
86
|
+
* same view of the inbound `resourceSubscriptions` filter the HTTP leg reads off
|
|
87
|
+
* `req.body`. The watcher's notify sink calls `sendResourceUpdated` on the
|
|
88
|
+
* pinned instance, which the router then delivers to the listening stream.
|
|
89
|
+
*
|
|
90
|
+
* Watcher leases are tracked by listen request ID and released on cancellation,
|
|
91
|
+
* rejection, graceful completion, or connection close.
|
|
92
|
+
*/
|
|
93
|
+
export function startServer(options, config = {}) {
|
|
94
|
+
let activeCtx;
|
|
95
|
+
const pathGuard = new PathGuard(options, true);
|
|
96
|
+
let pathGuardReady;
|
|
97
|
+
const ensurePathGuard = () => {
|
|
98
|
+
pathGuardReady ??= pathGuard.recomputeAllowedDirectories();
|
|
99
|
+
return pathGuardReady;
|
|
100
|
+
};
|
|
101
|
+
// Shared with the resource contract so a `resources/subscribe` and a
|
|
102
|
+
// `subscriptions/listen` naming the same URI reuse one watcher.
|
|
103
|
+
const registry = createWatcherRegistry();
|
|
104
|
+
const factory = async ({ era }) => {
|
|
105
|
+
await ensurePathGuard();
|
|
106
|
+
const c = await createServer(options, {
|
|
107
|
+
watcherRegistry: registry,
|
|
108
|
+
pathGuard,
|
|
109
|
+
era,
|
|
110
|
+
...(config.apiKey !== undefined ? { apiKey: config.apiKey } : {}),
|
|
111
|
+
});
|
|
112
|
+
activeCtx = c;
|
|
113
|
+
if (era === 'legacy') {
|
|
114
|
+
// Fires when the client's `notifications/initialized` lands. Safe to own:
|
|
115
|
+
// the SDK's only touchpoint is its own initialized handler reading it.
|
|
116
|
+
c.mcp.server.oninitialized = () => {
|
|
117
|
+
void seedRootsFromClient(c);
|
|
118
|
+
};
|
|
119
|
+
// Re-list and grant anything new. Grants are session-additive (R8): a
|
|
120
|
+
// root the client withdrew is not revoked mid-session.
|
|
121
|
+
c.mcp.server.setNotificationHandler('notifications/roots/list_changed', () => {
|
|
122
|
+
void seedRootsFromClient(c);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return c.mcp;
|
|
126
|
+
};
|
|
127
|
+
// One sink for the whole connection. `addCallback` de-duplicates by function
|
|
128
|
+
// identity, so re-using this closure makes a repeat `subscriptions/listen` on
|
|
129
|
+
// an already-watched URI a no-op; a fresh closure per listen would instead
|
|
130
|
+
// stack a callback every time, double-notifying and growing an
|
|
131
|
+
// `activeCallbacks` set that MAX_WATCHERS does not bound (it caps watchers,
|
|
132
|
+
// not callbacks). Reads `activeCtx` when it fires rather than capturing it, so
|
|
133
|
+
// it never pins a disposed instance.
|
|
134
|
+
const sink = (uri) => {
|
|
135
|
+
// A failed notify means the connection went away; nothing to recover.
|
|
136
|
+
void activeCtx?.mcp.server.sendResourceUpdated({ uri }).catch((err) => {
|
|
137
|
+
Logger.debug('[Stdio] resource update not delivered', {
|
|
138
|
+
uri,
|
|
139
|
+
error: formatUnknownErrorMessage(err),
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
const wire = new StdioServerTransport();
|
|
144
|
+
const listens = new Map();
|
|
145
|
+
// Deleting the entry is what makes this idempotent: a second call for the
|
|
146
|
+
// same id finds nothing to release.
|
|
147
|
+
const releaseListen = (id) => {
|
|
148
|
+
const state = listens.get(id);
|
|
149
|
+
if (!state)
|
|
150
|
+
return;
|
|
151
|
+
listens.delete(id);
|
|
152
|
+
for (const uri of state.acquiredUris)
|
|
153
|
+
registry.release(uri);
|
|
154
|
+
};
|
|
155
|
+
const send = wire.send.bind(wire);
|
|
156
|
+
wire.send = async (message) => {
|
|
157
|
+
if ('id' in message && ('result' in message || 'error' in message)) {
|
|
158
|
+
const id = message.id;
|
|
159
|
+
if (id !== undefined)
|
|
160
|
+
releaseListen(id);
|
|
161
|
+
}
|
|
162
|
+
await send(message);
|
|
163
|
+
};
|
|
164
|
+
const handle = serveStdio(factory, {
|
|
165
|
+
legacy: 'serve',
|
|
166
|
+
transport: wire,
|
|
167
|
+
onerror: (error) => {
|
|
168
|
+
Logger.error('[Stdio] serve error:', formatUnknownErrorMessage(error));
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
// Wrap the callback `serveStdio` just installed. Listen requests are admitted
|
|
172
|
+
// in order so two requests naming the same URI cannot race the registry's
|
|
173
|
+
// ref-count. Cancellation is serialized with pending admission by request ID:
|
|
174
|
+
// a pending request is suppressed and releases after preparation, while an
|
|
175
|
+
// active request releases before the SDK closes its stream.
|
|
176
|
+
//
|
|
177
|
+
// serveStdio installs its onmessage synchronously and only then starts the
|
|
178
|
+
// wire; this wrapper is only correct because of that ordering. Assert it
|
|
179
|
+
// rather than degrade to a silent no-op if a future SDK release changes it.
|
|
180
|
+
const deliver = wire.onmessage;
|
|
181
|
+
if (!deliver) {
|
|
182
|
+
throw new Error('serveStdio did not install a synchronous onmessage handler; the subscriptions/listen watcher gate cannot attach. This is an SDK contract change, not a configuration error.');
|
|
183
|
+
}
|
|
184
|
+
let gated = Promise.resolve();
|
|
185
|
+
wire.onmessage = (message) => {
|
|
186
|
+
const cancelId = cancelledRequestId(message);
|
|
187
|
+
if (cancelId !== null) {
|
|
188
|
+
const state = listens.get(cancelId);
|
|
189
|
+
if (!state) {
|
|
190
|
+
deliver(message);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
state.cancelled = true;
|
|
194
|
+
if (state.delivered) {
|
|
195
|
+
releaseListen(cancelId);
|
|
196
|
+
deliver(message);
|
|
197
|
+
}
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const subscriptionUris = listenSubscriptionUris(message);
|
|
201
|
+
if (subscriptionUris.length === 0) {
|
|
202
|
+
deliver(message);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const id = jsonRpcRequestId(message);
|
|
206
|
+
if (id === null || listens.has(id)) {
|
|
207
|
+
deliver(message);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const state = {
|
|
211
|
+
acquiredUris: [],
|
|
212
|
+
cancelled: false,
|
|
213
|
+
delivered: false,
|
|
214
|
+
};
|
|
215
|
+
listens.set(id, state);
|
|
216
|
+
gated = gated
|
|
217
|
+
.then(async () => {
|
|
218
|
+
if (!isStructurallyValidListen(message)) {
|
|
219
|
+
listens.delete(id);
|
|
220
|
+
deliver(message);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
if (isListenCancelled(state)) {
|
|
224
|
+
listens.delete(id);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
await ensurePathGuard();
|
|
228
|
+
const prepared = await prepareListenWatchers(message, pathGuard, registry, sink);
|
|
229
|
+
if (!prepared.ok) {
|
|
230
|
+
listens.delete(id);
|
|
231
|
+
await wire.send({
|
|
232
|
+
jsonrpc: JSONRPC_VERSION,
|
|
233
|
+
id,
|
|
234
|
+
error: { code: ProtocolErrorCode.InvalidParams, message: prepared.message },
|
|
235
|
+
});
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
state.acquiredUris = prepared.acquiredUris;
|
|
239
|
+
if (isListenCancelled(state)) {
|
|
240
|
+
releaseListen(id);
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
state.delivered = true;
|
|
244
|
+
deliver(message);
|
|
245
|
+
})
|
|
246
|
+
.catch(async (error) => {
|
|
247
|
+
releaseListen(id);
|
|
248
|
+
const failure = error instanceof Error ? error : new Error(formatUnknownErrorMessage(error));
|
|
249
|
+
wire.onerror?.(failure);
|
|
250
|
+
// The gate swallowed the message, so nothing downstream will answer it.
|
|
251
|
+
// Without this the client waits out its whole request timeout.
|
|
252
|
+
await wire
|
|
253
|
+
.send({
|
|
254
|
+
jsonrpc: JSONRPC_VERSION,
|
|
255
|
+
id,
|
|
256
|
+
error: { code: ProtocolErrorCode.InternalError, message: failure.message },
|
|
257
|
+
})
|
|
258
|
+
.catch(() => {
|
|
259
|
+
/* the wire is gone; onerror above already reported it */
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
};
|
|
263
|
+
return {
|
|
264
|
+
close: async () => {
|
|
265
|
+
for (const id of [...listens.keys()])
|
|
266
|
+
releaseListen(id);
|
|
267
|
+
registry.destroy();
|
|
268
|
+
try {
|
|
269
|
+
activeCtx?.disposeRuntimeState();
|
|
270
|
+
}
|
|
271
|
+
catch {
|
|
272
|
+
/* idempotent — disposeRuntimeState guards cleanedUp */
|
|
273
|
+
}
|
|
274
|
+
activeCtx = undefined;
|
|
275
|
+
await handle.close();
|
|
276
|
+
},
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
//# sourceMappingURL=stdio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdio.js","sourceRoot":"","sources":["../../src/transport/stdio.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAClF,OAAO,EACL,UAAU,EAEV,oBAAoB,GACrB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEpE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAQrB,gFAAgF;AAChF,0EAA0E;AAC1E,0DAA0D;AAC1D,SAAS,iBAAiB,CAAC,KAAuB;IAChD,OAAO,KAAK,CAAC,SAAS,CAAC;AACzB,CAAC;AAED,SAAS,kBAAkB,CAAC,OAAgB;IAC1C,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACj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,EAAE;gBACV,yDAAyD;YAC3D,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;IAEF,OAAO;QACL,KAAK,EAAE,KAAK,IAAI,EAAE;YAChB,KAAK,MAAM,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;gBAAE,aAAa,CAAC,EAAE,CAAC,CAAC;YACxD,QAAQ,CAAC,OAAO,EAAE,CAAC;YACnB,IAAI,CAAC;gBACH,SAAS,EAAE,mBAAmB,EAAE,CAAC;YACnC,CAAC;YAAC,MAAM,CAAC;gBACP,uDAAuD;YACzD,CAAC;YACD,SAAS,GAAG,SAAS,CAAC;YACtB,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// stdio hosting: the pinned-instance factory, legacy roots seeding, and the\n// gated transport that attaches listen-filter watchers before the SDK sees the\n// message.\nimport type { McpServerFactory } from '@modelcontextprotocol/server';\nimport { JSONRPC_VERSION, ProtocolErrorCode } from '@modelcontextprotocol/server';\nimport {\n serveStdio,\n type StdioServerHandle,\n StdioServerTransport,\n} from '@modelcontextprotocol/server/stdio';\n\nimport { fileURLToPath } from 'node:url';\n\nimport { formatUnknownErrorMessage } from '../core/errors.js';\nimport { Logger } from '../core/observability.js';\nimport type { ServerOptions } from '../core/path.js';\nimport { PathGuard } from '../core/path.js';\nimport { createWatcherRegistry } from '../core/watcher-registry.js';\nimport type { FilesystemServerContext } from '../server.js';\nimport { createServer } from '../server.js';\nimport type { RuntimeConfig } from './shared.js';\nimport {\n isStructurallyValidListen,\n jsonRpcRequestId,\n listenSubscriptionUris,\n prepareListenWatchers,\n} from './shared.js';\n\ninterface StdioListenState {\n acquiredUris: string[];\n cancelled: boolean;\n delivered: boolean;\n}\n\n// Read through a function, not `state.cancelled` directly: a cancellation lands\n// between the checks, and control-flow narrowing from the first one would\n// otherwise make the second read a compile-time constant.\nfunction isListenCancelled(state: StdioListenState): boolean {\n return state.cancelled;\n}\n\nfunction cancelledRequestId(message: unknown): string | number | null {\n if (typeof message !== 'object' || message === null) return null;\n const notification = message as {\n method?: unknown;\n params?: { requestId?: unknown };\n };\n if (notification.method !== 'notifications/cancelled') return null;\n const requestId = notification.params?.requestId;\n return typeof requestId === 'string' || typeof requestId === 'number' ? requestId : null;\n}\n\n/**\n * Seed the guard's allowed roots from the client's declared workspace roots.\n * Legacy-era only: push-style `roots/list` is deprecated (SEP-2577) and throws\n * on a 2026-07-28 connection, where clients pass paths as tool arguments and\n * the access-grant round-trip covers out-of-root paths instead. Every root\n * still passes `applyGrant`'s boundary and unsafe-path guards, so a client\n * cannot root-declare its way into $HOME or past FS_ROOT_BOUNDARY — a refused\n * root is skipped and its paths fail closed at validateAccess like any other.\n */\nexport async function seedRootsFromClient(ctx: FilesystemServerContext): Promise<number> {\n let roots: readonly { uri: string }[];\n try {\n // eslint-disable-next-line @typescript-eslint/no-deprecated -- legacy-era-only; the modern era never reaches the hooks that call this.\n ({ roots } = await ctx.mcp.server.listRoots());\n } catch (err: unknown) {\n // Client without the roots capability (strict-capabilities throw), or the\n // request failed — either way there is nothing to seed.\n Logger.debug('[Stdio] roots/list unavailable', { error: formatUnknownErrorMessage(err) });\n return 0;\n }\n let granted = 0;\n for (const root of roots) {\n let dir: string;\n try {\n dir = fileURLToPath(root.uri);\n } catch {\n continue; // not a file:// root\n }\n try {\n if (await ctx.pathGuard.applyGrant(dir)) granted += 1;\n else Logger.debug('[Stdio] client root refused by grant policy', { dir });\n } catch (err: unknown) {\n Logger.debug('[Stdio] client root grant failed', {\n dir,\n error: formatUnknownErrorMessage(err),\n });\n }\n }\n // No list-changed notification follows a grant. Allowed roots were once listed\n // as concrete resources, and are not any more: the file template's `list()`\n // returns nothing and the other two lists never read the roots at all (see\n // resources.ts). Notifying bought the client a re-fetch of an unchanged list.\n if (granted > 0) {\n Logger.info(`[Stdio] allowed ${granted} client-declared workspace root(s)`);\n }\n return granted;\n}\n\n/**\n * Serve filesystem-mcp over stdio using modern protocol revision 2026-07-28.\n *\n * The SDK's `StdioListenRouter` acknowledges `subscriptions/listen` and routes\n * the pinned instance's outbound change notifications onto the matching\n * streams, but it exposes no listen-filter hook, so nothing attaches the\n * filesystem watcher that would produce those notifications. `serveStdio`'s\n * `transport` option is the seam: it installs its own `onmessage` synchronously\n * and only then starts the wire, so wrapping that callback afterwards gives the\n * same view of the inbound `resourceSubscriptions` filter the HTTP leg reads off\n * `req.body`. The watcher's notify sink calls `sendResourceUpdated` on the\n * pinned instance, which the router then delivers to the listening stream.\n *\n * Watcher leases are tracked by listen request ID and released on cancellation,\n * rejection, graceful completion, or connection close.\n */\nexport function startServer(options: ServerOptions, config: RuntimeConfig = {}): StdioServerHandle {\n let activeCtx: FilesystemServerContext | undefined;\n const pathGuard = new PathGuard(options, true);\n let pathGuardReady: Promise<void> | undefined;\n const ensurePathGuard = (): Promise<void> => {\n pathGuardReady ??= pathGuard.recomputeAllowedDirectories();\n return pathGuardReady;\n };\n // Shared with the resource contract so a `resources/subscribe` and a\n // `subscriptions/listen` naming the same URI reuse one watcher.\n const registry = createWatcherRegistry();\n const factory: McpServerFactory = async ({ era }) => {\n await ensurePathGuard();\n const c = await createServer(options, {\n watcherRegistry: registry,\n pathGuard,\n era,\n ...(config.apiKey !== undefined ? { apiKey: config.apiKey } : {}),\n });\n activeCtx = c;\n if (era === 'legacy') {\n // Fires when the client's `notifications/initialized` lands. Safe to own:\n // the SDK's only touchpoint is its own initialized handler reading it.\n c.mcp.server.oninitialized = () => {\n void seedRootsFromClient(c);\n };\n // Re-list and grant anything new. Grants are session-additive (R8): a\n // root the client withdrew is not revoked mid-session.\n c.mcp.server.setNotificationHandler('notifications/roots/list_changed', () => {\n void seedRootsFromClient(c);\n });\n }\n return c.mcp;\n };\n\n // One sink for the whole connection. `addCallback` de-duplicates by function\n // identity, so re-using this closure makes a repeat `subscriptions/listen` on\n // an already-watched URI a no-op; a fresh closure per listen would instead\n // stack a callback every time, double-notifying and growing an\n // `activeCallbacks` set that MAX_WATCHERS does not bound (it caps watchers,\n // not callbacks). Reads `activeCtx` when it fires rather than capturing it, so\n // it never pins a disposed instance.\n const sink = (uri: string): void => {\n // A failed notify means the connection went away; nothing to recover.\n void activeCtx?.mcp.server.sendResourceUpdated({ uri }).catch((err: unknown) => {\n Logger.debug('[Stdio] resource update not delivered', {\n uri,\n error: formatUnknownErrorMessage(err),\n });\n });\n };\n\n const wire = new StdioServerTransport();\n const listens = new Map<string | number, StdioListenState>();\n\n // Deleting the entry is what makes this idempotent: a second call for the\n // same id finds nothing to release.\n const releaseListen = (id: string | number): void => {\n const state = listens.get(id);\n if (!state) return;\n listens.delete(id);\n for (const uri of state.acquiredUris) registry.release(uri);\n };\n\n const send = wire.send.bind(wire);\n wire.send = async (message) => {\n if ('id' in message && ('result' in message || 'error' in message)) {\n const id = message.id;\n if (id !== undefined) releaseListen(id);\n }\n await send(message);\n };\n\n const handle = serveStdio(factory, {\n legacy: 'serve',\n transport: wire,\n onerror: (error: unknown) => {\n Logger.error('[Stdio] serve error:', formatUnknownErrorMessage(error));\n },\n });\n\n // Wrap the callback `serveStdio` just installed. Listen requests are admitted\n // in order so two requests naming the same URI cannot race the registry's\n // ref-count. Cancellation is serialized with pending admission by request ID:\n // a pending request is suppressed and releases after preparation, while an\n // active request releases before the SDK closes its stream.\n //\n // serveStdio installs its onmessage synchronously and only then starts the\n // wire; this wrapper is only correct because of that ordering. Assert it\n // rather than degrade to a silent no-op if a future SDK release changes it.\n const deliver = wire.onmessage;\n if (!deliver) {\n throw new Error(\n 'serveStdio did not install a synchronous onmessage handler; the subscriptions/listen watcher gate cannot attach. This is an SDK contract change, not a configuration error.',\n );\n }\n let gated = Promise.resolve();\n wire.onmessage = (message) => {\n const cancelId = cancelledRequestId(message);\n if (cancelId !== null) {\n const state = listens.get(cancelId);\n if (!state) {\n deliver(message);\n return;\n }\n state.cancelled = true;\n if (state.delivered) {\n releaseListen(cancelId);\n deliver(message);\n }\n return;\n }\n\n const subscriptionUris = listenSubscriptionUris(message);\n if (subscriptionUris.length === 0) {\n deliver(message);\n return;\n }\n const id = jsonRpcRequestId(message);\n if (id === null || listens.has(id)) {\n deliver(message);\n return;\n }\n const state: StdioListenState = {\n acquiredUris: [],\n cancelled: false,\n delivered: false,\n };\n listens.set(id, state);\n gated = gated\n .then(async () => {\n if (!isStructurallyValidListen(message)) {\n listens.delete(id);\n deliver(message);\n return;\n }\n if (isListenCancelled(state)) {\n listens.delete(id);\n return;\n }\n await ensurePathGuard();\n const prepared = await prepareListenWatchers(message, pathGuard, registry, sink);\n if (!prepared.ok) {\n listens.delete(id);\n await wire.send({\n jsonrpc: JSONRPC_VERSION,\n id,\n error: { code: ProtocolErrorCode.InvalidParams, message: prepared.message },\n });\n return;\n }\n state.acquiredUris = prepared.acquiredUris;\n if (isListenCancelled(state)) {\n releaseListen(id);\n return;\n }\n state.delivered = true;\n deliver(message);\n })\n .catch(async (error: unknown) => {\n releaseListen(id);\n const failure =\n error instanceof Error ? error : new Error(formatUnknownErrorMessage(error));\n wire.onerror?.(failure);\n // The gate swallowed the message, so nothing downstream will answer it.\n // Without this the client waits out its whole request timeout.\n await wire\n .send({\n jsonrpc: JSONRPC_VERSION,\n id,\n error: { code: ProtocolErrorCode.InternalError, message: failure.message },\n })\n .catch(() => {\n /* the wire is gone; onerror above already reported it */\n });\n });\n };\n\n return {\n close: async () => {\n for (const id of [...listens.keys()]) releaseListen(id);\n registry.destroy();\n try {\n activeCtx?.disposeRuntimeState();\n } catch {\n /* idempotent — disposeRuntimeState guards cleanedUp */\n }\n activeCtx = undefined;\n await handle.close();\n },\n };\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { RuntimeConfig } from './transport/shared.js';
|
|
2
|
+
export { listenSubscriptionUris } from './transport/shared.js';
|
|
3
|
+
export { seedRootsFromClient, startServer } from './transport/stdio.js';
|
|
4
|
+
export { startHttpServer } from './transport/http.js';
|
|
5
|
+
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAKA,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC","sourcesContent":["// Facade for the transport layer, preserving the package's `./transport`\n// export and existing import paths. The hosting itself lives in\n// `transport/stdio.ts` (pinned-instance stdio serving) and `transport/http.ts`\n// (per-request HTTP hosting); `transport/shared.ts` holds the pieces both\n// legs gate on.\nexport type { RuntimeConfig } from './transport/shared.js';\nexport { listenSubscriptionUris } from './transport/shared.js';\nexport { seedRootsFromClient, startServer } from './transport/stdio.js';\nexport { startHttpServer } from './transport/http.js';\n"]}
|