Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
be2e264
proof of concept: v2 monorepo, package split
KKonstantinov Dec 10, 2025
cfa0615
barrel exports, imports
KKonstantinov Dec 10, 2025
8922ada
add vitest config
KKonstantinov Dec 10, 2025
ebeacac
clean up
KKonstantinov Dec 10, 2025
d372e75
save commit
KKonstantinov Dec 10, 2025
4db8d1b
eslint, vitest setup; successful shared/ tests pass
KKonstantinov Dec 10, 2025
617f14e
save commit; successful tests; successful checks
KKonstantinov Dec 12, 2025
0446560
Merge branch 'main' of github.com:modelcontextprotocol/typescript-sdk…
KKonstantinov Dec 12, 2025
a089abc
save commit
KKonstantinov Dec 12, 2025
647e5f0
save commit
KKonstantinov Dec 12, 2025
6c0818f
lint fix
KKonstantinov Dec 12, 2025
ea354fc
main.yml fix
KKonstantinov Dec 12, 2025
951a234
main.yml fix
KKonstantinov Dec 12, 2025
a7e60b9
add packageManager in package.json
KKonstantinov Dec 12, 2025
9d1e86c
typecheck fix, test main.yml fix
KKonstantinov Dec 12, 2025
236e934
check:all fix
KKonstantinov Dec 12, 2025
f20be12
import fixes
KKonstantinov Dec 12, 2025
c9fcc39
test fix
KKonstantinov Dec 12, 2025
f939900
imports fix
KKonstantinov Dec 12, 2025
d9cd7fe
imports fix
KKonstantinov Dec 12, 2025
f057363
import sorting
KKonstantinov Dec 12, 2025
c3be975
clean up
KKonstantinov Dec 12, 2025
c3353c9
pr-pkg-new update
KKonstantinov Dec 12, 2025
f1c45f2
pkg-pr-new update
KKonstantinov Dec 12, 2025
3e0657f
test imports, pnpm catalogs, package.json cleanup
KKonstantinov Dec 12, 2025
9f519c5
introduce named catalogs, slim down dependencies to minimum required …
KKonstantinov Dec 12, 2025
3c11e9f
add pnpm minimum version in engines
KKonstantinov Dec 12, 2025
c182b5d
add packageManager to package.json
KKonstantinov Dec 12, 2025
3275de7
pkg-pr-new update
KKonstantinov Dec 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 37 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,47 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@v6

- name: Install pnpm
uses: pnpm/action-setup@v4
id: pnpm-install
with:
run_install: false
- uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
cache: pnpm
cache-dependency-path: pnpm-lock.yaml

- run: npm ci
- run: npm run check
- run: npm run build
- run: pnpm install
- run: pnpm run check:all
- run: pnpm run build:all

test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [18, 24]
node-version: [22, 24]

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@v6

- name: Install pnpm
uses: pnpm/action-setup@v4
id: pnpm-install
with:
run_install: false
- uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: npm
cache: pnpm
cache-dependency-path: pnpm-lock.yaml

- run: pnpm install

- run: npm ci
- run: npm test
- run: pnpm test:all

publish:
runs-on: ubuntu-latest
Expand All @@ -55,13 +70,19 @@ jobs:

steps:
- uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4
id: pnpm-install
with:
run_install: false
- uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
registry-url: 'https://registry.npmjs.org'

- run: npm ci
- run: pnpm install

- name: Determine npm tag
id: npm-tag
Expand All @@ -84,6 +105,6 @@ jobs:
echo "tag=" >> $GITHUB_OUTPUT
fi

- run: npm publish --provenance --access public ${{ steps.npm-tag.outputs.tag }}
- run: pnpm publish --provenance --access public ${{ steps.npm-tag.outputs.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
30 changes: 22 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Publish Any Commit

permissions:
contents: read

on:
pull_request:
push:
Expand All @@ -14,14 +16,26 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@v6

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
run_install: false

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: pnpm install

- name: Build packages
run: pnpm run build:all

- run: npm ci
- name: Build
run: npm run build
- name: Publish
run: npx pkg-pr-new publish
- name: Publish preview packages
run: pnpm dlx pkg-pr-new publish --packageManager=pnpm --pnpm './packages/server' './packages/client'
26 changes: 17 additions & 9 deletions .github/workflows/update-spec-types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,35 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Install pnpm
uses: pnpm/action-setup@v4
id: pnpm-install
with:
run_install: false

- name: Setup Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: '24'
node-version: 24
cache: pnpm
cache-dependency-path: pnpm-lock.yaml

- name: Install dependencies
run: npm ci
run: pnpm install

- name: Fetch latest spec types
run: npm run fetch:spec-types
run: pnpm run fetch:spec-types

- name: Check for changes
id: check_changes
run: |
if git diff --quiet src/spec.types.ts; then
if git diff --quiet packages/core/src/types/spec.types.ts; then
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "has_changes=true" >> $GITHUB_OUTPUT
LATEST_SHA=$(grep "Last updated from commit:" src/spec.types.ts | cut -d: -f2 | tr -d ' ')
LATEST_SHA=$(grep "Last updated from commit:" packages/core/src/types/spec.types.ts | cut -d: -f2 | tr -d ' ')
echo "sha=$LATEST_SHA" >> $GITHUB_OUTPUT
fi

Expand All @@ -48,12 +56,12 @@ jobs:
git config user.email "github-actions[bot]@users.noreply.github.com"

git checkout -B update-spec-types
git add src/spec.types.ts
git add packages/core/src/types/spec.types.ts
git commit -m "chore: update spec.types.ts from upstream"
git push -f origin update-spec-types

# Create PR if it doesn't exist, or update if it does
PR_BODY="This PR updates \`src/spec.types.ts\` from the Model Context Protocol specification.
PR_BODY="This PR updates \`packages/core/src/types/spec.types.ts\` from the Model Context Protocol specification.

Source file: https://github.com/modelcontextprotocol/modelcontextprotocol/blob/${{ steps.check_changes.outputs.sha }}/schema/draft/schema.ts

Expand Down
79 changes: 79 additions & 0 deletions common/eslint-config/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// @ts-check
import path from 'node:path';
import { fileURLToPath } from 'node:url';

import eslint from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier/flat';
import importPlugin from 'eslint-plugin-import';
import nodePlugin from 'eslint-plugin-n';
import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort';
import tseslint from 'typescript-eslint';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
importPlugin.flatConfigs.recommended,
importPlugin.flatConfigs.typescript,
{
languageOptions: {
parserOptions: {
// Ensure consumers of this shared config get a stable tsconfig root
tsconfigRootDir: __dirname
}
},
linterOptions: {
reportUnusedDisableDirectives: false
},
plugins: {
n: nodePlugin,
'simple-import-sort': simpleImportSortPlugin
},
settings: {
'import/resolver': {
typescript: {
// Let the TS resolver handle NodeNext-style imports like "./foo.js"
extensions: ['.js', '.jsx', '.ts', '.tsx', '.d.ts'],
// Use the tsconfig in each package root (when running ESLint from that package)
project: 'tsconfig.json'
}
}
},
rules: {
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'n/prefer-node-protocol': 'error',
'@typescript-eslint/consistent-type-imports': ['error', { disallowTypeAnnotations: false }],
'simple-import-sort/imports': 'warn',
'simple-import-sort/exports': 'warn',
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'**/test/**',
'**/*.test.ts',
'**/*.test.tsx',
'**/scripts/**',
'**/vitest.config.*',
'**/eslint.config.*',
'**/vitest.setup.*'
],
optionalDependencies: false,
peerDependencies: true
}
]
}
},
{
// Ignore generated protocol types everywhere
ignores: ['**/spec.types.ts']
},
{
files: ['src/client/**/*.ts', 'src/server/**/*.ts'],
ignores: ['**/*.test.ts'],
rules: {
'no-console': 'error'
}
},
eslintConfigPrettier
);
36 changes: 36 additions & 0 deletions common/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "@modelcontextprotocol/eslint-config",
"private": true,
"main": "eslint.config.mjs",
"type": "module",
"exports": {
".": "./eslint.config.mjs"
},
"dependencies": {
"typescript": "catalog:devTools"
},
"repository": {
"type": "git",
"url": "https://github.com/modelcontextprotocol/typescript-sdk.git"
},
"bugs": {
"url": "https://github.com/modelcontextprotocol/typescript-sdk/issues"
},
"homepage": "https://github.com/modelcontextprotocol/typescript-sdk/tree/develop/common/eslint-config",
"publishConfig": {
"registry": "https://npm.pkg.github.com/"
},
"version": "2.0.0",
"devDependencies": {
"@eslint/js": "catalog:devTools",
"eslint": "catalog:devTools",
"eslint-config-prettier": "catalog:devTools",
"eslint-import-resolver-typescript": "^4.4.4",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-n": "catalog:devTools",
"eslint-plugin-simple-import-sort": "^12.1.1",
"prettier": "catalog:devTools",
"typescript": "catalog:devTools",
"typescript-eslint": "catalog:devTools"
}
}
21 changes: 21 additions & 0 deletions common/tsconfig/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@modelcontextprotocol/tsconfig",
"private": true,
"main": "tsconfig.json",
"type": "module",
"dependencies": {
"typescript": "catalog:devTools"
},
"repository": {
"type": "git",
"url": "https://github.com/modelcontextprotocol/typescript-sdk.git"
},
"bugs": {
"url": "https://github.com/modelcontextprotocol/typescript-sdk/issues"
},
"homepage": "https://github.com/modelcontextprotocol/typescript-sdk/tree/develop/common/ts-config",
"publishConfig": {
"registry": "https://npm.pkg.github.com/"
},
"version": "2.0.0"
}
20 changes: 14 additions & 6 deletions tsconfig.json → common/tsconfig/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
{
"compilerOptions": {
"target": "es2018",
"module": "Node16",
"moduleResolution": "Node16",
"target": "esnext",
"lib": ["esnext"],
"module": "NodeNext",
"moduleResolution": "NodeNext",
"allowSyntheticDefaultImports": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"libReplacement": false,
"noImplicitReturns": true,
"incremental": true,
"declaration": true,
"declarationMap": true,
"sourceMap": true,
Expand All @@ -17,7 +27,5 @@
"pkce-challenge": ["./node_modules/pkce-challenge/dist/index.node"]
},
"types": ["node", "vitest/globals"]
},
"include": ["src/**/*", "test/**/*"],
"exclude": ["node_modules", "dist"]
}
}
28 changes: 28 additions & 0 deletions common/vitest-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "@modelcontextprotocol/vitest-config",
"private": true,
"main": "vitest.config.mjs",
"type": "module",
"exports": {
".": "./vitest.config.js"
},
"dependencies": {
"typescript": "catalog:devTools"
},
"repository": {
"type": "git",
"url": "https://github.com/modelcontextprotocol/typescript-sdk.git"
},
"bugs": {
"url": "https://github.com/modelcontextprotocol/typescript-sdk/issues"
},
"homepage": "https://github.com/modelcontextprotocol/typescript-sdk/tree/develop/common/vitest-config",
"publishConfig": {
"registry": "https://npm.pkg.github.com/"
},
"version": "2.0.0",
"devDependencies": {
"@modelcontextprotocol/tsconfig": "workspace:^",
"vite-tsconfig-paths": "catalog:devTools"
}
}
Loading
Loading