From bec9f0a1cabe1a2756782da2b45470dbdaf48ea5 Mon Sep 17 00:00:00 2001 From: Matt Carey Date: Mon, 3 Nov 2025 22:05:00 +0000 Subject: [PATCH 1/3] feat: tsgo --- .github/workflows/main.yml | 2 +- package-lock.json | 118 ++++++++++++++++++++ package.json | 3 + src/client/streamableHttp.ts | 5 +- src/examples/server/simpleStreamableHttp.ts | 4 +- src/server/sse.test.ts | 2 +- tsconfig.json | 3 +- 7 files changed, 130 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5a7a84b35..7f4ba87c7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,9 +22,9 @@ jobs: cache: npm - run: npm ci + - run: npm run check - run: npm run build - run: npm test - - run: npm run lint publish: runs-on: ubuntu-latest diff --git a/package-lock.json b/package-lock.json index 40aa4b2e2..c6b3d1d7c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37,6 +37,7 @@ "@types/node": "^22.0.2", "@types/supertest": "^6.0.2", "@types/ws": "^8.5.12", + "@typescript/native-preview": "^7.0.0-dev.20251103.1", "eslint": "^9.8.0", "eslint-config-prettier": "^10.1.8", "jest": "^29.7.0", @@ -2231,6 +2232,123 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/@typescript/native-preview": { + "version": "7.0.0-dev.20251103.1", + "resolved": "https://registry.npmjs.org/@typescript/native-preview/-/native-preview-7.0.0-dev.20251103.1.tgz", + "integrity": "sha512-Pcyltv+XIbaCoRaD3btY3qu+B1VzvEgNGlq1lM0O11QTPRLHyoEfvtLqyPKuSDgD90gDbtCPGUppVkpQouLBVQ==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsgo": "bin/tsgo.js" + }, + "optionalDependencies": { + "@typescript/native-preview-darwin-arm64": "7.0.0-dev.20251103.1", + "@typescript/native-preview-darwin-x64": "7.0.0-dev.20251103.1", + "@typescript/native-preview-linux-arm": "7.0.0-dev.20251103.1", + "@typescript/native-preview-linux-arm64": "7.0.0-dev.20251103.1", + "@typescript/native-preview-linux-x64": "7.0.0-dev.20251103.1", + "@typescript/native-preview-win32-arm64": "7.0.0-dev.20251103.1", + "@typescript/native-preview-win32-x64": "7.0.0-dev.20251103.1" + } + }, + "node_modules/@typescript/native-preview-darwin-arm64": { + "version": "7.0.0-dev.20251103.1", + "resolved": "https://registry.npmjs.org/@typescript/native-preview-darwin-arm64/-/native-preview-darwin-arm64-7.0.0-dev.20251103.1.tgz", + "integrity": "sha512-yqUxUts3zpxy0x+Rk/9VC+ZiwzXTiuNpgLbhLAR1inFxuk0kTM8xoQERaIk+DUn6guEmRiCzOw23aJ9u6E+GfA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@typescript/native-preview-darwin-x64": { + "version": "7.0.0-dev.20251103.1", + "resolved": "https://registry.npmjs.org/@typescript/native-preview-darwin-x64/-/native-preview-darwin-x64-7.0.0-dev.20251103.1.tgz", + "integrity": "sha512-jboMuar6TgvnnOZk8t/X2gZp4TUtsP9xtUnLEMEHRPWK3LFBJpjDFRUH70vOpW9hWIKYajlkF8JutclCPX5sBQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@typescript/native-preview-linux-arm": { + "version": "7.0.0-dev.20251103.1", + "resolved": "https://registry.npmjs.org/@typescript/native-preview-linux-arm/-/native-preview-linux-arm-7.0.0-dev.20251103.1.tgz", + "integrity": "sha512-QY+0W9TPxHub8vSFjemo3txSpCNGw3LqnrLKKlGUIuLW+Ohproo+o7Fq21dksPQ4g0NDWY19qlm/36QhsXKRNQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@typescript/native-preview-linux-arm64": { + "version": "7.0.0-dev.20251103.1", + "resolved": "https://registry.npmjs.org/@typescript/native-preview-linux-arm64/-/native-preview-linux-arm64-7.0.0-dev.20251103.1.tgz", + "integrity": "sha512-PZewTo76n2chP8o0Fwq2543jVVSY7aiZMBsapB82+w/XecFuCQtFRYNN02x6pjHeVjgv5fcWS3+LzHa1zv10qw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@typescript/native-preview-linux-x64": { + "version": "7.0.0-dev.20251103.1", + "resolved": "https://registry.npmjs.org/@typescript/native-preview-linux-x64/-/native-preview-linux-x64-7.0.0-dev.20251103.1.tgz", + "integrity": "sha512-wdFUmmz5XFUvWQ54l3f8ODah86b6Z4FnG9gndjOdYRY2FGDCOdmeoBqLHDiGUIzTHr5FMMyz2EfScN+qtUh4Dw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@typescript/native-preview-win32-arm64": { + "version": "7.0.0-dev.20251103.1", + "resolved": "https://registry.npmjs.org/@typescript/native-preview-win32-arm64/-/native-preview-win32-arm64-7.0.0-dev.20251103.1.tgz", + "integrity": "sha512-A00+b8mbwJ4RFwXZN4vNcIBGZcdBCFm23lBhw8uaUgLY1Ot81FZvJE3YZcbRrZwEiyrwd3hAMdnDBWUwMA9YqA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@typescript/native-preview-win32-x64": { + "version": "7.0.0-dev.20251103.1", + "resolved": "https://registry.npmjs.org/@typescript/native-preview-win32-x64/-/native-preview-win32-x64-7.0.0-dev.20251103.1.tgz", + "integrity": "sha512-25Pqk65M3fjQdsnwBLym5ALSdQlQAqHKrzZOkIs1uFKxIfZ5s9658Kjfj2fiMX5m3imk9IqzpP+fvKbgP1plIw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/accepts": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", diff --git a/package.json b/package.json index 84c6b0906..65816b41c 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ ], "scripts": { "fetch:spec-types": "curl -o spec.types.ts https://raw.githubusercontent.com/modelcontextprotocol/modelcontextprotocol/refs/heads/main/schema/draft/schema.ts", + "typecheck": "tsgo --noEmit", "build": "npm run build:esm && npm run build:cjs", "build:esm": "mkdir -p dist/esm && echo '{\"type\": \"module\"}' > dist/esm/package.json && tsc -p tsconfig.prod.json", "build:esm:w": "npm run build:esm -- -w", @@ -69,6 +70,7 @@ "prepack": "npm run build:esm && npm run build:cjs", "lint": "eslint src/ && prettier --check .", "lint:fix": "eslint src/ --fix && prettier --write .", + "check": "npm run typecheck && npm run lint", "test": "npm run fetch:spec-types && jest", "start": "npm run server", "server": "tsx watch --clear-screen=false src/cli.ts server", @@ -111,6 +113,7 @@ "@types/node": "^22.0.2", "@types/supertest": "^6.0.2", "@types/ws": "^8.5.12", + "@typescript/native-preview": "^7.0.0-dev.20251103.1", "eslint": "^9.8.0", "eslint-config-prettier": "^10.1.8", "jest": "^29.7.0", diff --git a/src/client/streamableHttp.ts b/src/client/streamableHttp.ts index de3e5aa6a..b57013c33 100644 --- a/src/client/streamableHttp.ts +++ b/src/client/streamableHttp.ts @@ -311,7 +311,10 @@ export class StreamableHTTPClientTransport implements Transport { // if something happens reader will throw try { // Create a pipeline: binary stream -> text decoder -> SSE parser - const reader = stream.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream()).getReader(); + const reader = stream + .pipeThrough(new TextDecoderStream() as ReadableWritablePair) + .pipeThrough(new EventSourceParserStream()) + .getReader(); while (true) { const { value: event, done } = await reader.read(); diff --git a/src/examples/server/simpleStreamableHttp.ts b/src/examples/server/simpleStreamableHttp.ts index 5872cb4ac..6c970bdd1 100644 --- a/src/examples/server/simpleStreamableHttp.ts +++ b/src/examples/server/simpleStreamableHttp.ts @@ -15,8 +15,8 @@ import { } from '../../types.js'; import { InMemoryEventStore } from '../shared/inMemoryEventStore.js'; import { setupAuthServer } from './demoInMemoryOAuthProvider.js'; -import { OAuthMetadata } from 'src/shared/auth.js'; -import { checkResourceAllowed } from 'src/shared/auth-utils.js'; +import { OAuthMetadata } from '../../shared/auth.js'; +import { checkResourceAllowed } from '../../shared/auth-utils.js'; import cors from 'cors'; diff --git a/src/server/sse.test.ts b/src/server/sse.test.ts index 372cb689f..418094de2 100644 --- a/src/server/sse.test.ts +++ b/src/server/sse.test.ts @@ -5,7 +5,7 @@ import { McpServer } from './mcp.js'; import { createServer, type Server } from 'node:http'; import { AddressInfo } from 'node:net'; import { z } from 'zod'; -import { CallToolResult, JSONRPCMessage } from 'src/types.js'; +import { CallToolResult, JSONRPCMessage } from '../types.js'; const createMockResponse = () => { const res = { diff --git a/tsconfig.json b/tsconfig.json index 4cc22bf1b..b85703889 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,9 +13,8 @@ "resolveJsonModule": true, "isolatedModules": true, "skipLibCheck": true, - "baseUrl": ".", "paths": { - "pkce-challenge": ["node_modules/pkce-challenge/dist/index.node"] + "pkce-challenge": ["./node_modules/pkce-challenge/dist/index.node"] } }, "include": ["src/**/*"], From e8f9b2ecbd15f56e959465b6848c565471df8dcb Mon Sep 17 00:00:00 2001 From: Matt Carey Date: Mon, 3 Nov 2025 22:15:05 +0000 Subject: [PATCH 2/3] fix: spec types --- package.json | 2 +- src/spec.types.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 65816b41c..10e1a5fdf 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "dist" ], "scripts": { - "fetch:spec-types": "curl -o spec.types.ts https://raw.githubusercontent.com/modelcontextprotocol/modelcontextprotocol/refs/heads/main/schema/draft/schema.ts", + "fetch:spec-types": "curl -o ./src/spec.types.ts https://raw.githubusercontent.com/modelcontextprotocol/modelcontextprotocol/refs/heads/main/schema/draft/schema.ts", "typecheck": "tsgo --noEmit", "build": "npm run build:esm && npm run build:cjs", "build:esm": "mkdir -p dist/esm && echo '{\"type\": \"module\"}' > dist/esm/package.json && tsc -p tsconfig.prod.json", diff --git a/src/spec.types.test.ts b/src/spec.types.test.ts index 1f9083322..626eeef35 100644 --- a/src/spec.types.test.ts +++ b/src/spec.types.test.ts @@ -6,7 +6,7 @@ * (note: a few don't have SDK types, see MISSING_SDK_TYPES below) */ import * as SDKTypes from './types.js'; -import * as SpecTypes from '../spec.types.js'; +import * as SpecTypes from './spec.types.js'; import fs from 'node:fs'; /* eslint-disable @typescript-eslint/no-unused-vars */ @@ -443,7 +443,7 @@ const sdkTypeChecks = { }; // This file is .gitignore'd, and fetched by `npm run fetch:spec-types` (called by `npm run test`) -const SPEC_TYPES_FILE = 'spec.types.ts'; +const SPEC_TYPES_FILE = 'src/spec.types.ts'; const SDK_TYPES_FILE = 'src/types.ts'; const MISSING_SDK_TYPES = [ From 677c5a22c5f5935bd71086ec286cd88022befee8 Mon Sep 17 00:00:00 2001 From: Matt Carey Date: Mon, 3 Nov 2025 22:18:54 +0000 Subject: [PATCH 3/3] fetch types :( --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 10e1a5fdf..e8a8aa5a9 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "prepack": "npm run build:esm && npm run build:cjs", "lint": "eslint src/ && prettier --check .", "lint:fix": "eslint src/ --fix && prettier --write .", - "check": "npm run typecheck && npm run lint", + "check": "npm run fetch:spec-types && npm run typecheck && npm run lint", "test": "npm run fetch:spec-types && jest", "start": "npm run server", "server": "tsx watch --clear-screen=false src/cli.ts server",