From 512d59acd1391c63abc70201712b850735f992cb Mon Sep 17 00:00:00 2001 From: Burak Kaygusuz <17873574+burakkaygusuz@users.noreply.github.com> Date: Sat, 28 Nov 2026 15:56:06 +0300 Subject: [PATCH 1/5] docs(typescript-mcp-server-generator): update skill for MCP TypeScript SDK 2.x --- .../typescript-mcp-server-generator/SKILL.md | 328 ++++++++++++------ .../references/streamable-http.md | 113 ++++++ 2 files changed, 332 insertions(+), 109 deletions(-) create mode 100644 skills/typescript-mcp-server-generator/references/streamable-http.md diff --git a/skills/typescript-mcp-server-generator/SKILL.md b/skills/typescript-mcp-server-generator/SKILL.md index d7a98d272b..4338ae9cdc 100644 --- a/skills/typescript-mcp-server-generator/SKILL.md +++ b/skills/typescript-mcp-server-generator/SKILL.md @@ -1,113 +1,223 @@ --- name: typescript-mcp-server-generator -description: 'Generate a complete MCP server project in TypeScript using the MCP TypeScript SDK v2 (@modelcontextprotocol/server) with tools, resources, and proper configuration' +description: 'Use this skill when the user wants to create a new Model Context Protocol (MCP) server in TypeScript or Node.js. Also use it to expose TypeScript code, an API, or a database to AI clients as MCP tools. The skill makes an npm project with the MCP TypeScript SDK 2.x, Vitest tests, and client configuration. Do not use it for an MCP client or for a server in another language.' +compatibility: 'Node.js 22.12 or later on an LTS line (22, 24, or 26), npm, and network access to download packages. The minimum Node.js versions for the MCP Inspector are 22.23.4, 24.22.1, and 26.12.1, one for each LTS line.' --- -# Generate TypeScript MCP Server - -Create a complete Model Context Protocol (MCP) server in TypeScript using the **MCP TypeScript SDK v2** with the following specifications: - -## Requirements - -1. **Project Structure**: Create a new TypeScript/Node.js project with proper directory structure -2. **NPM Packages**: The v1 monolithic `@modelcontextprotocol/sdk` package is retired. Use the focused v2 packages: - - `@modelcontextprotocol/server` — server implementation (stdio transport via the `@modelcontextprotocol/server/stdio` subpath) - - `@modelcontextprotocol/node` — Node HTTP transport (`NodeStreamableHTTPServerTransport`), or a framework adapter: `@modelcontextprotocol/express`, `@modelcontextprotocol/hono`, `@modelcontextprotocol/fastify` — each adapter requires its peer framework to be installed alongside it (e.g. `@modelcontextprotocol/express` + `express`) - - `@modelcontextprotocol/core` — shared protocol schemas (import `*Schema` constants from here, not from `sdk/types.js`) - - `zod@^4.2` — v2 requires Zod 4.2+; do not use zod@3 -3. **Runtime**: Node.js 20+ (v2 minimum); ESM-first with `"type": "module"` (a CommonJS build is also shipped, so `require()` works if needed) -4. **Server Type**: Choose between HTTP (Streamable HTTP transport) or stdio-based server. SSE and WebSocket transports were removed in v2 — do not generate them. -5. **Tools**: Create at least one useful tool with proper schema validation -6. **Error Handling**: Include comprehensive error handling and validation - -## Implementation Details - -### Project Setup -- Initialize with `npm init` and create package.json -- Install dependencies: `@modelcontextprotocol/server`, `zod@^4.2`, and the transport package — `@modelcontextprotocol/node` for plain Node HTTP, or a framework adapter together with its peer framework (e.g. `npm install @modelcontextprotocol/express express`) -- Configure TypeScript with ES modules: `"type": "module"` in package.json -- Add dev dependencies: `tsx` or `ts-node` for development -- Create proper .gitignore file - -### Server Configuration -- Use `McpServer` class from `@modelcontextprotocol/server` for high-level implementation -- Set server name and version -- Choose the appropriate transport: - - HTTP (Node): `NodeStreamableHTTPServerTransport` from `@modelcontextprotocol/node` - - HTTP (Web Standard runtimes): `WebStandardStreamableHTTPServerTransport` from `@modelcontextprotocol/server` - - stdio: `StdioServerTransport` from `@modelcontextprotocol/server/stdio` -- For HTTP: prefer a framework adapter (`@modelcontextprotocol/express`, etc.) with proper middleware and error handling -- Note that v2 uses Web Standard `Headers`/`Request` types; read headers with `ctx.http?.req?.headers.get('x-custom')` - -### Tool Implementation -- Use `registerTool()` with a config object — v1 variadic `.tool()` signatures are gone: - ```typescript - server.registerTool('greet', { - description: 'Greet user', - inputSchema: z.object({ name: z.string() }) - }, async ({ name }, ctx) => { - return { content: [{ type: 'text', text: `Hello, ${name}!` }] }; - }); - ``` -- Schemas must be full Zod objects (`z.object({...})`) — raw shape objects (`{ name: z.string() }`) are deprecated -- Provide clear `title` and `description` fields -- Return both `content` and `structuredContent` in results -- The handler's second parameter is a structured `ctx` object (replaces v1 `extra`): `ctx.mcpReq.signal`, `ctx.mcpReq.id`, `ctx.mcpReq.send(...)`, `ctx.mcpReq.notify(...)` -- Implement proper error handling with try-catch blocks; use the v2 error hierarchy (`ProtocolError`, `SdkError`, `SdkHttpError` with `.status`) instead of v1 `McpError`/`StreamableHTTPError` -- Support async operations where appropriate - -### Resource/Prompt Setup (Optional) -- Add resources using `registerResource()` with ResourceTemplate for dynamic URIs -- Add prompts using `registerPrompt()` with argument schemas (same config-object style as `registerTool()`) -- Consider adding completion support for better UX; note the v2 `completable()` wrapper order: `completable(z.string(), callback).optional()` (optional applied outside) - -### Code Quality -- Use TypeScript for type safety -- Follow async/await patterns consistently -- Implement proper cleanup on transport close events -- Use environment variables for configuration -- Add inline comments for complex logic -- Structure code with clear separation of concerns - -## Example Tool Types to Consider -- Data processing and transformation -- External API integrations -- File system operations (read, search, analyze) -- Database queries -- Text analysis or summarization (LLM-assisted via the multi-round `input_required` pattern) -- System information retrieval - -## Configuration Options -- **For HTTP Servers**: - - Port configuration via environment variables - - CORS setup for browser clients - - Session management (stateless vs stateful) - - DNS rebinding protection for local servers - - Strict `Content-Type` handling: v2 rejects non-`application/json` POST bodies - -- **For stdio Servers**: - - Proper stdin/stdout handling - - Environment-based configuration - - Process lifecycle management - -## Migrating an Existing v1 Server -- Run the official codemod first: `npx @modelcontextprotocol/codemod@latest v1-to-v2 .` -- Then search for `@mcp-codemod-error` markers for the parts requiring manual judgment (transport choice, header reads, error classification) -- Swap `McpError + ErrorCode` checks for the new error classes; HTTP status now lives on `error.status`, not `error.code` -- `Server.createMessage()`, `listRoots()`, `sendLoggingMessage()` and the `roots`/`sampling`/`logging` capability fields are deprecated in v2 — avoid them in new code - -## Testing Guidance -- Explain how to run the server (`npm start` or `npx tsx server.ts`) -- Provide MCP Inspector command: `npx @modelcontextprotocol/inspector` -- For HTTP servers, include connection URL: `http://localhost:PORT/mcp` -- Include example tool invocations -- Add troubleshooting tips for common issues - -## Additional Features to Consider -- LLM-powered tools using the multi-round `input_required` pattern (the v2 replacement for the deprecated sampling subsystem) -- User input elicitation for interactive workflows -- Dynamic tool registration with enable/disable capabilities -- Notification debouncing for bulk updates -- Resource links for efficient data references - -Generate a complete, production-ready MCP server with comprehensive documentation, type safety, and error handling. +# TypeScript MCP Server Generator + +Create a Model Context Protocol (MCP) server in TypeScript with the official [MCP TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk) 2.x. SDK 2.4.x implements the MCP specification revision [2026-07-28](https://modelcontextprotocol.io/specification/2026-07-28). A client enables it with `versionNegotiation`. By default, a client still uses the 2025 `initialize` handshake. + +## Workflow + +Copy this checklist. Use it to track your progress: + +- [ ] Step 1: Create the project. +- [ ] Step 2: Write the server. +- [ ] Step 3: Write the tests. +- [ ] Step 4: Build until the tests pass. +- [ ] Step 5: Configure the client. + +### Step 1: Create the project + +Make this layout: + +```text +project-name/ +├── package.json +├── tsconfig.json +├── src/index.ts +└── test/server.test.ts +``` + +Write `package.json`: + +```json +{ + "name": "my-mcp-server", + "version": "0.1.0", + "type": "module", + "bin": { "my-mcp-server": "dist/index.js" }, + "scripts": { + "build": "tsc", + "dev": "tsx src/index.ts", + "start": "node dist/index.js", + "test": "vitest run" + } +} +``` + +Write `tsconfig.json`: + +```json +{ + "compilerOptions": { + "target": "es2022", + "module": "nodenext", + "moduleResolution": "nodenext", + "strict": true, + "types": ["node"], + "rootDir": "src", + "outDir": "dist" + }, + "include": ["src"] +} +``` + +Install the dependencies: + +```bash +npm install @modelcontextprotocol/server zod@^4.2 +npm install -D typescript@^7.0.2 @types/node@^22 tsx vitest@^5.1.2 @modelcontextprotocol/client +``` + +- `@modelcontextprotocol/server` contains `McpServer` and the stdio entry `@modelcontextprotocol/server/stdio`. +- `@modelcontextprotocol/client` is only for the tests. +- `tsx` runs the server during development. Do not use Node.js native TypeScript execution. + +### Step 2: Write the server + +Start from this template in `src/index.ts`: + +```typescript +#!/usr/bin/env node +import { McpServer } from '@modelcontextprotocol/server'; +import { serveStdio } from '@modelcontextprotocol/server/stdio'; +import * as z from 'zod/v4'; + +function createServer(): McpServer { + const server = new McpServer({ name: 'demo', version: '0.1.0' }); + + server.registerTool( + 'divide', + { + title: 'Divide', + description: 'Divide a by b.', + inputSchema: z.object({ + a: z.number().describe('Dividend'), + b: z.number().describe('Divisor') + }), + outputSchema: z.object({ result: z.number() }) + }, + async ({ a, b }) => { + if (b === 0) { + return { content: [{ type: 'text', text: 'b must not be zero.' }], isError: true }; + } + const result = a / b; + return { + content: [{ type: 'text', text: JSON.stringify({ result }) }], + structuredContent: { result } + }; + } + ); + + return server; +} + +void serveStdio(createServer); +console.error('demo MCP server running on stdio'); +``` + +Then change the template to match the request of the user: + +1. Replace the `divide` tool with the tools that the user asks for. +2. Give each tool a zod `inputSchema` (`z.object({ ... })`), a `title`, and a `description`. The description tells the model when to use the tool. +3. When the client must get machine-readable data, add an `outputSchema`. Return the data in `structuredContent`. Also return the same data as serialized JSON in a text block for older clients. +4. Mark a read-only tool with `annotations: { readOnlyHint: true }`. +5. Add resources (`registerResource`) and prompts (`registerPrompt`) only when the user asks for them. + +Use stdio by default. Read [references/streamable-http.md](references/streamable-http.md) only when the user asks for a remote server or HTTP. + +### Step 3: Write the tests + +The test starts the built server as a subprocess. It connects to the server with the SDK client. Write a test for each tool and for each error result in `test/server.test.ts`: + +```typescript +import { Client } from '@modelcontextprotocol/client'; +import { StdioClientTransport } from '@modelcontextprotocol/client/stdio'; +import { afterAll, beforeAll, expect, test } from 'vitest'; + +let client: Client; + +beforeAll(async () => { + client = new Client({ name: 'test-client', version: '1.0.0' }, { versionNegotiation: { mode: { pin: '2026-07-28' } } }); + await client.connect(new StdioClientTransport({ command: process.execPath, args: ['dist/index.js'] })); +}); + +afterAll(async () => { + await client.close(); +}); + +test('negotiates the 2026-07-28 revision', () => { + expect(client.getNegotiatedProtocolVersion()).toBe('2026-07-28'); +}); + +test('divide', async () => { + const result = await client.callTool({ name: 'divide', arguments: { a: 6, b: 3 } }); + expect(result.structuredContent).toEqual({ result: 2 }); +}); + +test('divide by zero', async () => { + const result = await client.callTool({ name: 'divide', arguments: { a: 1, b: 0 } }); + expect(result.isError).toBe(true); + expect(JSON.stringify(result.content)).toContain('must not be zero'); +}); +``` + +- For an HTTP server, use the test setup in [references/streamable-http.md](references/streamable-http.md). +- The test runs `dist/index.js`. Run `npm run build` before `npm test`. +- `process.execPath` is the `node` command that runs the tests. Do not use the `node` command from `PATH`. +- The test uses the real stdio transport and the real JSON-RPC messages. +- The `pin` option makes the client use the revision 2026-07-28. Without it, the client uses the 2025 handshake. + +### Step 4: Build until the tests pass + +1. Run `npm run build && npm test`. This command compiles the code to `dist/` and runs the tests. +2. If a test or the compiler fails, read the error. Fix the server or the test. +3. Run `npm run build && npm test` again. +4. Continue only when the build and all tests pass. + +### Step 5: Configure the client + +For VS Code, write `.vscode/mcp.json`: + +```json +{ + "servers": { + "demo": { + "type": "stdio", + "command": "node", + "args": ["/absolute/path/to/project/dist/index.js"] + } + } +} +``` + +For Claude Desktop, put the same `command` and `args` in `claude_desktop_config.json`, below the `mcpServers` key. + +For an HTTP server, use the client configuration in [references/streamable-http.md](references/streamable-http.md). + +Tell the user these facts: + +- `node dist/index.js` starts the stdio server. The server waits for a host on stdin. The logs go to stderr. +- To test the server manually, run `npx @modelcontextprotocol/inspector node dist/index.js`. The minimum Node.js versions for the MCP Inspector are 22.23.4, 24.22.1, and 26.12.1, one for each LTS line. + +## Gotchas + +SDK 2.x changed many patterns of the v1 package `@modelcontextprotocol/sdk`. Do not copy examples from v1. To update an existing server, run `npx @modelcontextprotocol/codemod@latest v1-to-v2 .`. Then search for `@mcp-codemod-error` markers. Read the [upgrade guide](https://ts.sdk.modelcontextprotocol.io/v2/migration/upgrade-to-v2.html) for the full list. + +- Use the focused v2 packages. Do not install `@modelcontextprotocol/sdk`. The SDK removed the SSE server transport and the WebSocket client transport. The frozen copy of the old SSE code is only in `@modelcontextprotocol/server-legacy`. +- The SDK does not support Zod 3. Use `zod@^4.2` and give schemas as `z.object({ ... })`. The raw shape form `{ name: z.string() }` is deprecated. +- Use `registerTool()`, `registerResource()`, and `registerPrompt()`. The variadic `tool()` methods do not exist. +- If a tool has an `outputSchema`, return `structuredContent` in each successful result. +- Write `completable(z.string(), callback).optional()`. Put `.optional()` on the outside. +- Return a result with `isError: true` for an error that the model must read. The v2 error classes are `ProtocolError`, `SdkError`, and `SdkHttpError` (with `.status`). `McpError` and `StreamableHTTPError` do not exist. +- In a stdio server, stdout is the protocol channel. Do not call `console.log()`. Use `console.error()`. +- There are no sessions and no `initialize` handshake on 2026-07-28. Per-call state lives in handles that the server makes and the model passes as tool arguments. +- The SDK answers `server/discover`, fills `resultType`, and routes `subscriptions/listen`. Do not write them manually. +- Do not use `ctx.mcpReq.elicitInput()`. It throws on a 2026-07-28 request. Return `inputRequired({ inputRequests: { ... } })`. Read the answer with `acceptedContent(ctx.mcpReq.inputResponses, 'id', schema)`. Use the same zod schema that you gave to `inputRequired.elicit`. The content comes from the client and is untrusted. To keep state between the retries, return `requestState` in `inputRequired(...)`. `requestState` comes back from the client. Treat it as untrusted input. Create one codec at module scope, outside the factory, with `createRequestStateCodec({ key })` from `@modelcontextprotocol/server`. Load a key of at least 32 bytes from the configuration. Each server process must use the same key. Pass a `bind` function that returns the user and `ctx.mcpReq.method`. Every tool call has the method `tools/call`. Thus, also put the tool name and the important arguments in the state. On the retry, reject the state if they do not match the call. Return `requestState: await codec.mint(state, ctx)` in `inputRequired(...)`. Set `requestState: { verify: codec.verify }` in the `McpServer` options. Read the state with `ctx.mcpReq.requestState()`. The codec signs the state but does not encrypt it. Do not put secrets in the state. +- The revision 2026-07-28 deprecates sampling, MCP logging, and roots ([SEP-2577](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577)). They continue to work for at least twelve months. HTTP+SSE is deprecated since 2025-03-26 (SEP-2596). It can be removed three months after SEP-2596 becomes final. Do not add these features to a new server: + - **Sampling** (`server.server.createMessage()`): Call the LLM provider API directly. If existing code must keep sampling, use `inputRequired.createMessage`. + - **MCP logging** (`ctx.mcpReq.log`): Log to stderr or use OpenTelemetry. + - **Roots**: Get paths from tool arguments, resource URIs, or the server configuration. + - **HTTP+SSE**: Use Streamable HTTP for a remote server. diff --git a/skills/typescript-mcp-server-generator/references/streamable-http.md b/skills/typescript-mcp-server-generator/references/streamable-http.md new file mode 100644 index 0000000000..216d0a9439 --- /dev/null +++ b/skills/typescript-mcp-server-generator/references/streamable-http.md @@ -0,0 +1,113 @@ +# Streamable HTTP Servers + +Use this transport only for a remote server. A local server uses stdio. + +## Express server + +`createMcpHandler` converts the server factory into a web-standard HTTP handler. `toNodeHandler` adapts it to the `(req, res)` functions of Node.js. `createMcpExpressApp` is `express()` with `express.json()` and DNS rebinding protection. Add the packages: + +```bash +npm install @modelcontextprotocol/express @modelcontextprotocol/node express +npm install -D @types/express +``` + +Move `createServer()` and its imports to `src/server.ts`, and export it. In `src/index.ts`, keep the shebang line. Replace the rest of the file with: + +```typescript +import { createMcpExpressApp } from '@modelcontextprotocol/express'; +import { toNodeHandler } from '@modelcontextprotocol/node'; +import { createMcpHandler } from '@modelcontextprotocol/server'; + +import { createServer } from './server.js'; + +const app = createMcpExpressApp(); +const node = toNodeHandler(createMcpHandler(createServer)); +app.all('/mcp', (req, res) => void node(req, res, req.body)); + +const port = Number(process.env.PORT ?? 3000); +app.listen(port, '127.0.0.1', () => console.error(`demo MCP server listening on http://127.0.0.1:${port}/mcp`)); +``` + +`createMcpExpressApp` already parses the JSON body. Pass `req.body` as the third argument of the handler, so that it does not read the stream again. + +Read a request header in a handler with `ctx.http?.req?.headers.get('x-custom')`. The `ctx` object is the last parameter of the handler. + +## Other frameworks and runtimes + +For a runtime with web-standard `Request` and `Response` objects, call `handler.fetch(request)` directly: + +```typescript +import { createMcpHandler, hostHeaderValidationResponse, originValidationResponse } from '@modelcontextprotocol/server'; + +const handler = createMcpHandler(createServer); + +export default { + async fetch(request: Request): Promise { + const rejected = + hostHeaderValidationResponse(request, ['api.example.com']) ?? originValidationResponse(request, ['app.example.com']); + return rejected ?? handler.fetch(request); + } +}; +``` + +The SDK also has adapters for Hono and Fastify. Read the [SDK documentation](https://ts.sdk.modelcontextprotocol.io/v2/) for them. + +## Tests + +The stdio test of Step 3 does not work for an HTTP server. The test imports `createServer` from `dist/server.js`, so it does not start the server. Add `"declaration": true` to `tsconfig.json`. With this option, the test gets the types of `createServer`. In `test/server.test.ts`, replace all lines above the first `test(` call with: + +```typescript +import { Client, StreamableHTTPClientTransport } from '@modelcontextprotocol/client'; +import { createMcpHandler, type McpHttpHandler } from '@modelcontextprotocol/server'; +import { afterAll, beforeAll, expect, test } from 'vitest'; + +import { createServer } from '../dist/server.js'; + +let client: Client; +let handler: McpHttpHandler; + +beforeAll(async () => { + handler = createMcpHandler(createServer); + client = new Client({ name: 'test-client', version: '1.0.0' }, { versionNegotiation: { mode: { pin: '2026-07-28' } } }); + await client.connect( + new StreamableHTTPClientTransport(new URL('http://test.local/mcp'), { + fetch: (url, init) => handler.fetch(new Request(url, init)) + }) + ); +}); + +afterAll(async () => { + await client.close(); + await handler.close(); +}); +``` + +Close the client first, then the handler. The client sends each request to `handler.fetch` in the test process. The test opens no port. Keep the other tests. + +## Client configuration + +For VS Code, write `.vscode/mcp.json`: + +```json +{ + "servers": { + "demo": { + "type": "http", + "url": "http://127.0.0.1:3000/mcp" + } + } +} +``` + +## Gotchas + +- `createMcpHandler` does not check the `Host` and `Origin` headers. Without a check, a malicious web page can use DNS rebinding to call a local server. `createMcpExpressApp` checks `Host` and `Origin` for a `127.0.0.1` bind. Pass the same host to `app.listen`. Do not use the deprecated `enableDnsRebindingProtection` option. When you bind to all interfaces, the default protection ends. Name the hosts that you serve: `createMcpExpressApp({ host: '0.0.0.0', allowedHosts: ['api.example.com'], allowedOrigins: ['app.example.com'] })`, and call `app.listen(port, '0.0.0.0', ...)`. Also name the browser origins in `allowedOrigins`. Without it, the app does not check `Origin` on this bind. On a web-standard runtime, put `hostHeaderValidationResponse` and `originValidationResponse` from `@modelcontextprotocol/server` in front of the handler. On plain `node:http`, use `localhostHostValidation` and `localhostOriginValidation` from `@modelcontextprotocol/node`. `createMcpHonoApp` and `createMcpFastifyApp` enable the protection by default. +- `createMcpHandler(factory)` also serves 2025 clients by default, without sessions. To serve only the revision 2026-07-28, use `createMcpHandler(factory, { legacy: 'reject' })`. To keep a 2025 server that has sessions, call `await isLegacyRequest(request)` in front of a strict handler. It returns a promise. Send the requests for which it resolves to `false` to the strict handler. In an Express app, the body parser reads the stream first. Make the `Request` with `await toWebRequest(req, req.body)` from `@modelcontextprotocol/node`. +- The revision 2026-07-28 removes `Mcp-Session-Id`. Each Streamable HTTP POST request needs the `MCP-Protocol-Version` and `Mcp-Method` headers. A `tools/call`, `resources/read`, or `prompts/get` request also needs `Mcp-Name`. `createMcpHandler` answers HTTP 400 with `-32020` when a header is missing or does not match the body. If a browser client calls the server, add `MCP-Protocol-Version`, `Mcp-Method`, and `Mcp-Name` to `Access-Control-Allow-Headers` in your framework. +- The POST `Content-Type` must be `application/json`. Otherwise the server answers with HTTP 415. +- The server is stateless. The factory runs for each request. Keep the factory cheap. Create database pools, API clients, and caches once at module scope. Use them in the factory. There are no sessions. Per-call state lives in handles that the server makes and the model passes as ordinary tool arguments. Use `requestState` only for the state between the retries of an `inputRequired` result. +- Mark a tool parameter with `x-mcp-header` to copy it into the `Mcp-Param-{Name}` header. Use it only for `string`, `integer`, and `boolean` parameters. Do not mark a secret or personal data with `x-mcp-header`. Network intermediaries can read headers. A browser SDK client does not send `Mcp-Param-*` headers. Thus, `createMcpHandler` rejects a call that has a value for such a parameter. Do not use `x-mcp-header` on a tool that a browser client calls. For an integer, use `z.int()`, not `z.number()`. If a header does not match the body, `createMcpHandler` answers with HTTP 400 and the code `-32020`. +- `NodeStreamableHTTPServerTransport` from `@modelcontextprotocol/node` is only for 2025-era clients. +- The HTTP+SSE transport of 2024-11-05 is deprecated (SEP-2596). Use Streamable HTTP. Streamable HTTP still sends SSE response streams. The revision 2026-07-28 removes SSE resumability and `Last-Event-ID`. A client repeats a broken request with a new ID. +- `createMcpHandler` does not verify tokens. It passes `authInfo` to the handler as it gets it. Verify the token in a middleware in front of the handler, for example with `requireBearerAuth` from `@modelcontextprotocol/express`. +- Use the `PORT` environment variable for the port. From 97c342784d42d8a73a4ac69a13bf23428585f2d9 Mon Sep 17 00:00:00 2001 From: Burak Kaygusuz <17873574+burakkaygusuz@users.noreply.github.com> Date: Sat, 28 Nov 2026 15:56:06 +0300 Subject: [PATCH 2/5] docs(typescript-mcp-expert): update agent for MCP TypeScript SDK 2.x --- agents/typescript-mcp-expert.agent.md | 137 +++++++++++++------------- 1 file changed, 68 insertions(+), 69 deletions(-) diff --git a/agents/typescript-mcp-expert.agent.md b/agents/typescript-mcp-expert.agent.md index 13ee18b153..1c531f409d 100644 --- a/agents/typescript-mcp-expert.agent.md +++ b/agents/typescript-mcp-expert.agent.md @@ -1,92 +1,91 @@ --- -description: "Expert assistant for developing Model Context Protocol (MCP) servers in TypeScript" -name: "TypeScript MCP Server Expert" -model: GPT-4.1 +description: 'Expert assistant that helps developers build Model Context Protocol (MCP) servers in TypeScript with the MCP TypeScript SDK 2.x' +name: 'TypeScript MCP Expert' +model: 'GPT-6.2 Sol' --- -# TypeScript MCP Server Expert +# TypeScript MCP Expert -You are a world-class expert in building Model Context Protocol (MCP) servers using the TypeScript SDK. You have deep knowledge of the @modelcontextprotocol/sdk package, Node.js, TypeScript, async programming, zod validation, and best practices for building robust, production-ready MCP servers. +You are an expert in Model Context Protocol (MCP) servers with the [MCP TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk) 2.x (`@modelcontextprotocol/server` and the other v2 packages). You know `McpServer`, `serveStdio`, `createMcpHandler`, zod 4, Node.js, and TypeScript. You know the MCP specification revision [2026-07-28](https://modelcontextprotocol.io/specification/2026-07-28), which SDK 2.4.x supports. A client enables it with `versionNegotiation`. You help developers build reliable, production-ready MCP servers. ## Your Expertise -- **TypeScript MCP SDK**: Complete mastery of @modelcontextprotocol/sdk, including McpServer, Server, all transports, and utility functions -- **TypeScript/Node.js**: Expert in TypeScript, ES modules, async/await patterns, and Node.js ecosystem -- **Schema Validation**: Deep knowledge of zod for input/output validation and type inference -- **MCP Protocol**: Complete understanding of the Model Context Protocol specification, transports, and capabilities -- **Transport Types**: Expert in both StreamableHTTPServerTransport (with Express) and StdioServerTransport -- **Tool Design**: Creating intuitive, well-documented tools with proper schemas and error handling -- **Best Practices**: Security, performance, testing, type safety, and maintainability -- **Debugging**: Troubleshooting transport issues, schema validation errors, and protocol problems +- **TypeScript MCP SDK**: The packages `@modelcontextprotocol/server`, `@modelcontextprotocol/client`, `@modelcontextprotocol/node`, and `@modelcontextprotocol/express`, `McpServer`, and the registration functions +- **TypeScript and Node.js**: ES modules, async/await, `tsx`, and Node.js 22.12 or later on an LTS line (22, 24, or 26) +- **Schema Validation**: zod 4 for input and output schemas and type inference +- **MCP Protocol**: The 2026-07-28 revision, and the features that it deprecates: sampling, roots, and logging (SEP-2577), and Dynamic Client Registration (PR #2858). HTTP+SSE is also deprecated (SEP-2596) +- **Transport Types**: stdio with `serveStdio`, and Streamable HTTP with `createMcpHandler`, `toNodeHandler`, and `createMcpExpressApp` for Express +- **Tool Design**: Tools with correct schemas, structured output, and clear descriptions +- **Best Practices**: Tests, error handling, logs, type safety, and security +- **Problem Analysis**: Schema validation errors, transport errors, and stdout corruption ## Your Approach -- **Understand Requirements**: Always clarify what the MCP server needs to accomplish and who will use it -- **Choose Right Tools**: Select appropriate transport (HTTP vs stdio) based on use case -- **Type Safety First**: Leverage TypeScript's type system and zod for runtime validation -- **Follow SDK Patterns**: Use `registerTool()`, `registerResource()`, `registerPrompt()` methods consistently -- **Structured Returns**: Always return both `content` (for display) and `structuredContent` (for data) from tools -- **Error Handling**: Implement comprehensive try-catch blocks and return `isError: true` for failures -- **LLM-Friendly**: Write clear titles and descriptions that help LLMs understand tool capabilities -- **Test-Driven**: Consider how tools will be tested and provide testing guidance +- **Understand Use Case**: Check if the server is for local (stdio) or remote (HTTP) use. +- **Stdio by Default**: Use `serveStdio(createServer)` for a local server. Use HTTP only when the user asks for a remote server. +- **SDK 2.x Only**: Do not use code from the v1 package `@modelcontextprotocol/sdk`. +- **Full Schemas**: Give `inputSchema`, `outputSchema`, and `argsSchema` as `z.object({ ... })` values. The raw shape form is deprecated. +- **Structured Output**: Set `outputSchema`. Return `structuredContent` for machine-readable data. Also return the same data as text content. +- **Error Handling**: Return a result with `isError: true` and a clear message for errors that the model must read. Throw `ProtocolError` only in resource, prompt, and completion callbacks. +- **Test Early**: Test with the SDK `Client` in a Vitest test before integration. ## Guidelines -- Always use ES modules syntax (`import`/`export`, not `require`) -- Import from specific SDK paths: `@modelcontextprotocol/sdk/server/mcp.js` -- Use zod for all schema definitions: `{ inputSchema: { param: z.string() } }` -- Provide `title` field for all tools, resources, and prompts (not just `name`) -- Return both `content` and `structuredContent` from tool implementations -- Use `ResourceTemplate` for dynamic resources: `new ResourceTemplate('resource://{param}', { list: undefined })` -- Create new transport instances per request in stateless HTTP mode -- Enable DNS rebinding protection for local HTTP servers: `enableDnsRebindingProtection: true` -- Configure CORS and expose `Mcp-Session-Id` header for browser clients -- Use `completable()` wrapper for argument completion support -- Implement sampling with `server.server.createMessage()` when tools need LLM help -- Use `server.server.elicitInput()` for interactive user input during tool execution -- Handle cleanup with `res.on('close', () => transport.close())` for HTTP transports -- Use environment variables for configuration (ports, API keys, paths) -- Add proper TypeScript types for all function parameters and returns -- Implement graceful error handling and meaningful error messages -- Test with MCP Inspector: `npx @modelcontextprotocol/inspector` +- Use ES modules syntax (`import` and `export`, not `require`). +- Import from the package root: `import { McpServer } from '@modelcontextprotocol/server'`. Import `serveStdio` from `@modelcontextprotocol/server/stdio`. +- Use `registerTool()`, `registerResource()`, and `registerPrompt()`. +- Provide a `title` for all tools, resources, and prompts. +- If a tool has an `outputSchema`, return `structuredContent` in each successful result. Without it, the SDK returns a tool result with `isError` set to `true`. +- Use `ResourceTemplate` for dynamic resources: `new ResourceTemplate('resource://{param}', { list: undefined })`. +- Write `completable(schema, callback).optional()`. Put `.optional()` on the outside. +- Register tools, resources, and prompts inside the factory. Do not register them on a shared instance. The server is stateless on HTTP: `createMcpHandler(factory)` calls the factory for each request. Keep the factory cheap. Create database pools, API clients, and caches once at module scope. Use them in the factory. There are no sessions and no `initialize` handshake on 2026-07-28. +- Do not use `enableDnsRebindingProtection`. It is deprecated. `createMcpHandler` does not check the `Host` and `Origin` headers. Use `createMcpExpressApp`, which protects `127.0.0.1` by default. As an alternative, add `hostHeaderValidation` and `originValidation` from `@modelcontextprotocol/node` or `@modelcontextprotocol/express` in front of the handler. When you bind to all interfaces, pass `allowedHosts` and `allowedOrigins` to `createMcpExpressApp`. +- Each Streamable HTTP POST request needs the `MCP-Protocol-Version` and `Mcp-Method` headers. A `tools/call`, `resources/read`, or `prompts/get` request also needs `Mcp-Name`. `createMcpHandler` answers HTTP 400 with `-32020` when a header is missing or does not match the body. +- Do not use `ctx.mcpReq.elicitInput()`. It throws on a 2026-07-28 request. Return `inputRequired({ inputRequests: { id: inputRequired.elicit({ ... }) } })`. On the retry, read the answer with `acceptedContent(ctx.mcpReq.inputResponses, 'id', schema)`. Use the same zod schema that you gave to `inputRequired.elicit`. There is no `elicitationId`. Use `requestState` to link the retries. `requestState` comes back from the client. Treat it as untrusted input. Create one codec at module scope, outside the factory, with `createRequestStateCodec({ key })` from `@modelcontextprotocol/server`. Load a key of at least 32 bytes from the configuration. Each server process must use the same key. Pass a `bind` function that returns the user and `ctx.mcpReq.method`. Every tool call has the method `tools/call`. Thus, also put the tool name and the important arguments in the state. On the retry, reject the state if they do not match the call. Return `requestState: await codec.mint(state, ctx)` in `inputRequired(...)`. Set `requestState: { verify: codec.verify }` in the `McpServer` options. Read the state with `ctx.mcpReq.requestState()`. The codec signs the state but does not encrypt it. Do not put secrets in the state. For a browser flow, use `inputRequired.elicitUrl(...)`. +- Do not use sampling (`server.server.createMessage()`). It is deprecated (SEP-2577). Call the LLM provider API directly. If existing code must keep sampling, use `inputRequired.createMessage` on 2026-07-28 connections. +- Do not use MCP logging (`ctx.mcpReq.log`). It is deprecated (SEP-2577). Use OpenTelemetry as an alternative. Do not add the `logging` capability to a new server. +- Do not use roots. They are deprecated (SEP-2577). Take directories or files as tool parameters, resource URIs, or server configuration. +- In a stdio server, stdout is the protocol channel. Write logs to stderr. +- The v2 error classes are `ProtocolError`, `SdkError`, and `SdkHttpError` (with `.status`). `McpError` does not exist. +- Do not define your own error codes in the range `-32768` to `-32000`. The specification reserves `-32020` to `-32099`. Do not use the legacy codes `-32000` to `-32019` in a new server. +- Use environment variables for configuration (ports, API keys, paths). +- Test with the MCP Inspector: `npx @modelcontextprotocol/inspector`. ## Common Scenarios You Excel At -- **Creating New Servers**: Generating complete project structures with package.json, tsconfig, and proper setup -- **Tool Development**: Implementing tools for data processing, API calls, file operations, or database queries -- **Resource Implementation**: Creating static or dynamic resources with proper URI templates -- **Prompt Development**: Building reusable prompt templates with argument validation and completion -- **Transport Setup**: Configuring both HTTP (with Express) and stdio transports correctly -- **Debugging**: Diagnosing transport issues, schema validation errors, and protocol problems -- **Optimization**: Improving performance, adding notification debouncing, and managing resources efficiently -- **Migration**: Helping migrate from older MCP implementations to current best practices -- **Integration**: Connecting MCP servers with databases, APIs, or other services -- **Testing**: Writing tests and providing integration testing strategies +- **New Servers**: Generate complete npm projects with `package.json`, `tsconfig.json`, and tests +- **Tool Development**: Write tools that process data or use APIs, files, or databases +- **Resource Implementation**: Create static resources and resource templates +- **Prompt Development**: Write reusable prompts with argument completion +- **Transport Setup**: Configure stdio for local use or Streamable HTTP for remote access +- **Problem Analysis**: Find schema validation errors, transport problems, and stdout corruption +- **Migration**: Upgrade servers from `@modelcontextprotocol/sdk` to the v2 packages with `npx @modelcontextprotocol/codemod@latest v1-to-v2 .` +- **Integration**: Connect servers to databases, APIs, or other services +- **Tests**: Write Vitest tests that use the SDK client ## Response Style -- Provide complete, working code that can be copied and used immediately -- Include all necessary imports at the top of code blocks -- Add inline comments explaining important concepts or non-obvious code -- Show package.json and tsconfig.json when creating new projects -- Explain the "why" behind architectural decisions -- Highlight potential issues or edge cases to watch for -- Suggest improvements or alternative approaches when relevant -- Include MCP Inspector commands for testing -- Format code with proper indentation and TypeScript conventions -- Provide environment variable examples when needed +- Give complete code that the user can copy and run immediately. +- Put all necessary imports at the top. +- Add inline comments for important or unclear code. +- Show `package.json` and `tsconfig.json` for new projects. Use `module: nodenext` and `types: ["node"]` in `tsconfig.json`. +- Explain the reason for design decisions. +- Show possible problems and edge cases. +- Suggest improvements or alternative approaches when they are relevant. +- Include the npm commands for build and test. +- Format code with the correct TypeScript conventions. +- Give environment variable examples when necessary. ## Advanced Capabilities You Know -- **Dynamic Updates**: Using `.enable()`, `.disable()`, `.update()`, `.remove()` for runtime changes -- **Notification Debouncing**: Configuring debounced notifications for bulk operations -- **Session Management**: Implementing stateful HTTP servers with session tracking -- **Backwards Compatibility**: Supporting both Streamable HTTP and legacy SSE transports -- **OAuth Proxying**: Setting up proxy authorization with external providers -- **Context-Aware Completion**: Implementing intelligent argument completions based on context -- **Resource Links**: Returning ResourceLink objects for efficient large file handling -- **Sampling Workflows**: Building tools that use LLM sampling for complex operations -- **Elicitation Flows**: Creating interactive tools that request user input during execution -- **Low-Level API**: Using the Server class directly for maximum control when needed +- **Dynamic Updates**: Change the tool, prompt, or resource set only when server-wide data changes, not as a side effect of a request. On stdio, `.enable()`, `.disable()`, `.update()`, and `.remove()` on registered items send list change notifications. On HTTP, change the data that the factory reads, then call `handler.notify.toolsChanged()`, `promptsChanged()`, `resourcesChanged()`, or `resourceUpdated(uri)` on the result of `createMcpHandler`. +- **Notification Debouncing**: `debouncedNotificationMethods` for bulk updates +- **Stateless Servers**: Per-call state lives in handles that the server makes and the model passes as ordinary tool arguments (SEP-2567). +- **Legacy Clients**: `createMcpHandler(factory, { legacy: 'reject' })` serves only 2026-07-28. The default serves 2025 clients without sessions. `isLegacyRequest` routes a 2025 server that has sessions. `NodeStreamableHTTPServerTransport` is only for 2025-era clients. +- **SSE**: v2 removes the SSE server transport. The frozen copy is only in `@modelcontextprotocol/server-legacy`. +- **Multi-Round Requests**: `inputRequired` and `acceptedContent` for elicitation in the middle of a tool call +- **Context-Aware Completion**: Argument completion with `completable()` +- **Resource Links**: Return `resource_link` content for large files +- **Low-Level API**: The `Server` class with `server.setRequestHandler('tools/call', async (request, ctx) => { ... })` for maximum control -You help developers build high-quality TypeScript MCP servers that are type-safe, robust, performant, and easy for LLMs to use effectively. +You help developers build TypeScript MCP servers that are correct, reliable, well documented, and easy for LLMs to use. From e97aff012e82a06db6e4856d0c89cbce48620356 Mon Sep 17 00:00:00 2001 From: Burak Kaygusuz <17873574+burakkaygusuz@users.noreply.github.com> Date: Sat, 28 Nov 2026 15:56:06 +0300 Subject: [PATCH 3/5] docs(typescript-mcp-server): update instructions for MCP TypeScript SDK 2.x --- .../typescript-mcp-server.instructions.md | 375 ++++++++++-------- 1 file changed, 209 insertions(+), 166 deletions(-) diff --git a/instructions/typescript-mcp-server.instructions.md b/instructions/typescript-mcp-server.instructions.md index 97185e6c05..7e23db9e8c 100644 --- a/instructions/typescript-mcp-server.instructions.md +++ b/instructions/typescript-mcp-server.instructions.md @@ -1,228 +1,271 @@ --- -description: 'Instructions for building Model Context Protocol (MCP) servers using the TypeScript SDK' -applyTo: '**/*.ts, **/*.js, **/package.json' +description: 'Instructions to build Model Context Protocol (MCP) servers in TypeScript with the MCP TypeScript SDK 2.x' +applyTo: '**/*.ts, **/*.js, **/package.json, **/tsconfig.json' --- # TypeScript MCP Server Development +These instructions apply to the [MCP TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk) 2.x. SDK 2.4.x implements the MCP specification revision [2026-07-28](https://modelcontextprotocol.io/specification/2026-07-28). A client enables it with `versionNegotiation`. By default, a client still uses the 2025 `initialize` handshake. + +> **Scope:** Apply these instructions only to projects that use the MCP TypeScript SDK 2.x directly. Do not apply them to code that uses the v1 package `@modelcontextprotocol/sdk`. Update that code first with the codemod. These instructions do not cover the Hono and Fastify adapters. + ## Instructions -- Use the **@modelcontextprotocol/sdk** npm package: `npm install @modelcontextprotocol/sdk` -- Import from specific paths: `@modelcontextprotocol/sdk/server/mcp.js`, `@modelcontextprotocol/sdk/server/stdio.js`, etc. -- Use `McpServer` class for high-level server implementation with automatic protocol handling -- Use `Server` class for low-level control with manual request handlers -- Use **zod** for input/output schema validation: `npm install zod@3` -- Always provide `title` field for tools, resources, and prompts for better UI display -- Use `registerTool()`, `registerResource()`, and `registerPrompt()` methods (recommended over older APIs) -- Define schemas using zod: `{ inputSchema: { param: z.string() }, outputSchema: { result: z.string() } }` -- Return both `content` (for display) and `structuredContent` (for structured data) from tools -- For HTTP servers, use `StreamableHTTPServerTransport` with Express or similar frameworks -- For local integrations, use `StdioServerTransport` for stdio-based communication -- Create new transport instances per request to prevent request ID collisions (stateless mode) -- Use session management with `sessionIdGenerator` for stateful servers -- Enable DNS rebinding protection for local servers: `enableDnsRebindingProtection: true` -- Configure CORS headers and expose `Mcp-Session-Id` for browser-based clients -- Use `ResourceTemplate` for dynamic resources with URI parameters: `new ResourceTemplate('resource://{param}', { list: undefined })` -- Support completions for better UX using `completable()` wrapper from `@modelcontextprotocol/sdk/server/completable.js` -- Implement sampling with `server.server.createMessage()` to request LLM completions from clients -- Use `server.server.elicitInput()` to request additional user input during tool execution -- Enable notification debouncing for bulk updates: `debouncedNotificationMethods: ['notifications/tools/list_changed']` -- Dynamic updates: call `.enable()`, `.disable()`, `.update()`, or `.remove()` on registered items to emit `listChanged` notifications -- Use `getDisplayName()` from `@modelcontextprotocol/sdk/shared/metadataUtils.js` for UI display names -- Test servers with MCP Inspector: `npx @modelcontextprotocol/inspector` +- Use Node.js 22.12 or later on an LTS line (22, 24, or 26) with `"type": "module"`. Use a `tsconfig.json` with `module: nodenext` and `types: ["node"]`. +- Install the SDK with `npm install @modelcontextprotocol/server zod@^4.2`. The SDK does not support Zod 3. +- Do not use the v1 package `@modelcontextprotocol/sdk`. Run `npx @modelcontextprotocol/codemod@latest v1-to-v2 .` when you update a server. Then search for `@mcp-codemod-error` markers. Read the [upgrade guide](https://ts.sdk.modelcontextprotocol.io/v2/migration/upgrade-to-v2.html) for the rest. +- Import from the package root: `McpServer`, `ResourceTemplate`, `completable`, `getDisplayName`, `createMcpHandler`, `inputRequired`, and `acceptedContent` come from `@modelcontextprotocol/server`. +- Import `serveStdio` from `@modelcontextprotocol/server/stdio`. Import `toNodeHandler` from `@modelcontextprotocol/node`. Import `createMcpExpressApp` from `@modelcontextprotocol/express`. +- Use the `McpServer` class for most servers. Use the `Server` class only for low-level control. Register handlers with `server.setRequestHandler('tools/call', async (request, ctx) => { ... })`. +- Write `import * as z from 'zod/v4'`. Give `inputSchema`, `outputSchema`, and `argsSchema` as `z.object({ ... })` values. The raw shape form `{ param: z.string() }` is deprecated. +- Always provide a `title` for tools, resources, and prompts for better UI display. +- Use `registerTool()`, `registerResource()`, and `registerPrompt()`. The variadic `tool()`, `resource()`, and `prompt()` methods do not exist. +- Make a server in a factory function. Pass the factory to `serveStdio(createServer)` or to `createMcpHandler(createServer)`. +- For a local server, use `serveStdio(createServer)`. +- For a remote server, use Streamable HTTP: `toNodeHandler(createMcpHandler(createServer))`. For Express, attach it to the app that `createMcpExpressApp()` returns. +- An HTTP server is stateless. `createMcpHandler(factory)` calls the factory for each request. Keep the factory cheap. Create database pools, API clients, and caches once at module scope. Use them in the factory. There are no sessions, no `Mcp-Session-Id` header, and no `initialize` handshake on 2026-07-28. +- Do not use `sessionIdGenerator` or `NodeStreamableHTTPServerTransport` in a new server. The transport is only for 2025-era clients. +- `createMcpHandler` does not check the `Host` and `Origin` headers. `createMcpExpressApp` protects the default `127.0.0.1` bind. When you bind to all interfaces, pass `allowedHosts` and `allowedOrigins`. Do not use `enableDnsRebindingProtection`. It is deprecated. +- Each Streamable HTTP POST request needs the `MCP-Protocol-Version` and `Mcp-Method` headers. A `tools/call`, `resources/read`, or `prompts/get` request also needs `Mcp-Name`. `createMcpHandler` answers HTTP 400 with `-32020` when a header is missing or does not match the body. +- Return both `content` (for display) and `structuredContent` (for structured data) from a tool that has an `outputSchema`. +- Use `ResourceTemplate` for dynamic resources with URI parameters: `new ResourceTemplate('resource://{param}', { list: undefined })`. +- `registerResource()` always takes a metadata object. Use `{}` when you have no metadata. +- Support completions with `completable(schema, callback).optional()`. Put `.optional()` on the outside. +- Do not use `ctx.mcpReq.elicitInput()`. It throws on a 2026-07-28 request. Return `inputRequired({ inputRequests: { id: inputRequired.elicit({ message, requestedSchema }) } })`. On the retry, read the answer with `acceptedContent(ctx.mcpReq.inputResponses, 'id', schema)`. Use the same zod schema that you gave to `inputRequired.elicit`. +- For a flow in the browser, for example OAuth or a payment, use `inputRequired.elicitUrl(...)`. There is no `elicitationId`. Use `requestState` to link the retries. `requestState` comes back from the client. Treat it as untrusted input. Create one codec at module scope, outside the factory, with `createRequestStateCodec({ key })` from `@modelcontextprotocol/server`. Load a key of at least 32 bytes from the configuration. Each server process must use the same key. Pass a `bind` function that returns the user and `ctx.mcpReq.method`. Every tool call has the method `tools/call`. Thus, also put the tool name and the important arguments in the state. On the retry, reject the state if they do not match the call. Return `requestState: await codec.mint(state, ctx)` in `inputRequired(...)`. Set `requestState: { verify: codec.verify }` in the `McpServer` options. Read the state with `ctx.mcpReq.requestState()`. The codec signs the state but does not encrypt it. Do not put secrets in the state. +- Do not use sampling (`server.server.createMessage()`). The revision 2026-07-28 deprecates it. Call the LLM provider API directly. If existing code must keep sampling, use `inputRequired.createMessage` on 2026-07-28 connections. +- Do not use MCP logging (`ctx.mcpReq.log`). The revision 2026-07-28 deprecates it. Log to stderr or use OpenTelemetry. +- Do not use roots. The revision 2026-07-28 deprecates them. Get paths from tool arguments, resource URIs, or the server configuration. +- Enable notification debouncing for bulk updates: `new McpServer(info, { debouncedNotificationMethods: ['notifications/tools/list_changed'] })`. +- Dynamic updates: Change the tool, prompt, or resource set only when server-wide data changes, not as a side effect of a request. On stdio, `.enable()`, `.disable()`, `.update()`, and `.remove()` on registered items send list change notifications. On HTTP, change the data that the factory reads, then call `handler.notify.toolsChanged()`, `promptsChanged()`, `resourcesChanged()`, or `resourceUpdated(uri)` on the result of `createMcpHandler`. +- Use `getDisplayName()` for UI display names. +- Test a server with the SDK `Client` from `@modelcontextprotocol/client` and `StdioClientTransport` from `@modelcontextprotocol/client/stdio`. +- Test servers manually with the MCP Inspector: `npx @modelcontextprotocol/inspector`. ## Best Practices -- Keep tool implementations focused on single responsibilities -- Provide clear, descriptive titles and descriptions for LLM understanding -- Use proper TypeScript types for all parameters and return values -- Implement comprehensive error handling with try-catch blocks -- Return `isError: true` in tool results for error conditions -- Use async/await for all asynchronous operations -- Close database connections and clean up resources properly -- Validate input parameters before processing -- Use structured logging for debugging without polluting stdout/stderr -- Consider security implications when exposing file system or network access -- Implement proper resource cleanup on transport close events -- Use environment variables for configuration (ports, API keys, etc.) -- Document tool capabilities and limitations clearly -- Test with multiple clients to ensure compatibility +- Keep tool implementations focused on single responsibilities. +- Provide clear, descriptive titles and descriptions that the LLM can understand. +- Add a `.describe(...)` to each property in `inputSchema`. +- Use proper TypeScript types for all parameters and return values. +- Return `isError: true` in tool results for error conditions that the model must read. Do not throw for a tool failure. +- Use async/await for all asynchronous operations. +- Close database connections and release resources properly. +- Validate input parameters before processing. +- On stdio servers, stdout is the protocol channel: log to stderr. MCP logging (`ctx.mcpReq.log`) is deprecated (SEP-2577). Use stderr or OpenTelemetry. +- Register tools, resources, and prompts inside the factory. Do not register them on a shared instance. The tool list must not vary per connection or as a side effect of other requests. It can vary by the authorization of the request. The SDK lists tools in a deterministic order. +- Cacheable results carry `ttlMs` and `cacheScope`. The SDK uses `ttlMs: 0` and `cacheScope: 'private'` by default. Set `cacheHints` in the server options or `cacheHint` per resource. Do this only when the data is safe to cache. +- `outputSchema` and `inputSchema` can use any JSON Schema 2020-12 keyword. `structuredContent` can be any JSON value. +- Be careful when a tool gives access to the file system or the network. +- Use environment variables for configuration (for example ports and API keys). +- Document tool capabilities and limitations clearly. ## Common Patterns -### Basic Server Setup (HTTP) -```typescript -import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; -import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js'; -import express from 'express'; - -const server = new McpServer({ - name: 'my-server', - version: '1.0.0' -}); - -const app = express(); -app.use(express.json()); - -app.post('/mcp', async (req, res) => { - const transport = new StreamableHTTPServerTransport({ - sessionIdGenerator: undefined, - enableJsonResponse: true - }); - - res.on('close', () => transport.close()); - - await server.connect(transport); - await transport.handleRequest(req, res, req.body); -}); - -app.listen(3000); -``` +The snippets use `import * as z from 'zod/v4'`. Most of them show only the imports that they need. ### Basic Server Setup (stdio) + ```typescript -import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; -import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; +import { McpServer } from '@modelcontextprotocol/server'; +import { serveStdio } from '@modelcontextprotocol/server/stdio'; +import * as z from 'zod/v4'; -const server = new McpServer({ - name: 'my-server', - version: '1.0.0' -}); +function createServer(): McpServer { + const server = new McpServer({ name: 'my-server', version: '0.1.0' }); -// ... register tools, resources, prompts ... + server.registerTool( + 'add', + { + title: 'Add', + description: 'Add two numbers.', + inputSchema: z.object({ + a: z.number().describe('First number'), + b: z.number().describe('Second number') + }), + outputSchema: z.object({ sum: z.number() }) + }, + async ({ a, b }) => { + const sum = a + b; + return { + content: [{ type: 'text', text: JSON.stringify({ sum }) }], + structuredContent: { sum } + }; + } + ); -const transport = new StdioServerTransport(); -await server.connect(transport); + return server; +} + +void serveStdio(createServer); +console.error('my-server is running on stdio'); ``` -### Simple Tool -```typescript -import { z } from 'zod'; +### Tool with Structured Output +```typescript server.registerTool( - 'calculate', + 'word_count', { - title: 'Calculator', - description: 'Perform basic calculations', - inputSchema: { a: z.number(), b: z.number(), op: z.enum(['+', '-', '*', '/']) }, - outputSchema: { result: z.number() } + title: 'Word Count', + description: 'Count the words in a text.', + inputSchema: z.object({ text: z.string().describe('The text to count') }), + outputSchema: z.object({ words: z.number().int() }), + annotations: { readOnlyHint: true } }, - async ({ a, b, op }) => { - const result = op === '+' ? a + b : op === '-' ? a - b : - op === '*' ? a * b : a / b; - const output = { result }; + async ({ text }) => { + const words = text.trim() === '' ? 0 : text.trim().split(/\s+/).length; return { - content: [{ type: 'text', text: JSON.stringify(output) }], - structuredContent: output + content: [{ type: 'text', text: JSON.stringify({ words }) }], + structuredContent: { words } }; } ); ``` -### Dynamic Resource -```typescript -import { ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js'; +### Error Handling -server.registerResource( - 'user', - new ResourceTemplate('users://{userId}', { list: undefined }), +```typescript +server.registerTool( + 'divide', { - title: 'User Profile', - description: 'Fetch user profile data' + title: 'Divide', + description: 'Divide a by b.', + inputSchema: z.object({ a: z.number(), b: z.number() }) }, - async (uri, { userId }) => ({ - contents: [{ - uri: uri.href, - text: `User ${userId} data here` - }] - }) + async ({ a, b }) => { + if (b === 0) { + return { content: [{ type: 'text', text: 'b must not be zero.' }], isError: true }; + } + return { content: [{ type: 'text', text: String(a / b) }] }; + } ); ``` -### Tool with Sampling +A tool handler produces only tool errors. The SDK converts an exception from a tool handler into a result with `isError: true`. Resource, prompt, and completion callbacks have no `isError` channel. They throw `ProtocolError` (from `@modelcontextprotocol/server`). The v2 error classes are `ProtocolError`, `SdkError`, and `SdkHttpError` (with `.status`). + +A missing resource throws `ResourceNotFoundError`. The SDK answers with the code `-32602`. Custom error codes use a value outside `-32768` to `-32000`. Do not use the legacy codes `-32000` to `-32019` in a new server. The specification reserves `-32020` to `-32099`. `UnsupportedProtocolVersionError` (`-32022`) and `MissingRequiredClientCapabilityError` (`-32021`) are protocol errors that the SDK sends. They are not tool errors. + +### Resources and Resource Templates + ```typescript -server.registerTool( - 'summarize', - { - title: 'Text Summarizer', - description: 'Summarize text using LLM', - inputSchema: { text: z.string() }, - outputSchema: { summary: z.string() } - }, - async ({ text }) => { - const response = await server.server.createMessage({ - messages: [{ - role: 'user', - content: { type: 'text', text: `Summarize: ${text}` } - }], - maxTokens: 500 - }); - - const summary = response.content.type === 'text' ? - response.content.text : 'Unable to summarize'; - const output = { summary }; - return { - content: [{ type: 'text', text: JSON.stringify(output) }], - structuredContent: output - }; +import { ResourceNotFoundError, ResourceTemplate } from '@modelcontextprotocol/server'; + +server.registerResource( + 'config', + 'config://app', + { title: 'App Config', description: 'Application configuration', mimeType: 'application/json' }, + async uri => ({ + contents: [{ uri: uri.href, text: '{"debug":false}' }] + }) +); + +const users = new Map([['1', 'Ada']]); + +server.registerResource( + 'user', + new ResourceTemplate('users://{id}', { list: undefined }), + { title: 'User', description: 'A user by id' }, + async (uri, { id }) => { + const user = users.get(String(id)); + if (user === undefined) throw new ResourceNotFoundError(uri.href); + return { contents: [{ uri: uri.href, text: `User ${user}` }] }; } ); ``` ### Prompt with Completion + ```typescript -import { completable } from '@modelcontextprotocol/sdk/server/completable.js'; +import { completable } from '@modelcontextprotocol/server'; + +const languages = ['typescript', 'javascript', 'python', 'rust', 'go']; server.registerPrompt( - 'review', + 'code-review', { title: 'Code Review', - description: 'Review code with specific focus', - argsSchema: { - language: completable(z.string(), value => - ['typescript', 'python', 'javascript', 'java'] - .filter(l => l.startsWith(value)) - ), - code: z.string() - } + description: 'Review code in a language.', + argsSchema: z.object({ + language: completable(z.string().describe('Programming language'), value => + languages.filter(language => language.startsWith(value)) + ).optional() + }) }, - ({ language, code }) => ({ - messages: [{ - role: 'user', - content: { - type: 'text', - text: `Review this ${language} code:\n\n${code}` + ({ language }) => ({ + messages: [ + { + role: 'user' as const, + content: { type: 'text' as const, text: `Review this ${language ?? 'source'} code.` } } - }] + ] }) ); ``` -### Error Handling +### Async Tool with Progress + ```typescript server.registerTool( - 'risky-operation', + 'lookup', { - title: 'Risky Operation', - description: 'An operation that might fail', - inputSchema: { input: z.string() }, - outputSchema: { result: z.string() } + title: 'Lookup', + description: 'Look up a query in a slow backend.', + inputSchema: z.object({ query: z.string() }) }, - async ({ input }) => { - try { - const result = await performRiskyOperation(input); - const output = { result }; - return { - content: [{ type: 'text', text: JSON.stringify(output) }], - structuredContent: output - }; - } catch (err: unknown) { - const error = err as Error; - return { - content: [{ type: 'text', text: `Error: ${error.message}` }], - isError: true - }; + async ({ query }, ctx) => { + const progressToken = ctx.mcpReq._meta?.progressToken; + if (progressToken !== undefined) { + await ctx.mcpReq.notify({ + method: 'notifications/progress', + params: { progressToken, progress: 1, total: 2, message: 'Halfway' } + }); } + const text = await slowLookup(query); + return { content: [{ type: 'text', text }] }; } ); ``` + +Pass `ctx.mcpReq.signal` to the backend call to stop the work when the client cancels the request. + +### Streamable HTTP Server + +```typescript +import { createMcpExpressApp } from '@modelcontextprotocol/express'; +import { toNodeHandler } from '@modelcontextprotocol/node'; +import { createMcpHandler } from '@modelcontextprotocol/server'; + +const app = createMcpExpressApp(); +const node = toNodeHandler(createMcpHandler(createServer)); +app.all('/mcp', (req, res) => void node(req, res, req.body)); + +const port = Number(process.env.PORT ?? 3000); +app.listen(port, '127.0.0.1'); +``` + +`createMcpExpressApp` parses the JSON body. Pass `req.body` as the third argument of the handler. `createServer` is the factory from the stdio example. + +### Integration Test + +```typescript +import { Client } from '@modelcontextprotocol/client'; +import { StdioClientTransport } from '@modelcontextprotocol/client/stdio'; +import { afterAll, beforeAll, expect, test } from 'vitest'; + +let client: Client; + +beforeAll(async () => { + client = new Client({ name: 'test-client', version: '1.0.0' }, { versionNegotiation: { mode: { pin: '2026-07-28' } } }); + await client.connect(new StdioClientTransport({ command: process.execPath, args: ['dist/index.js'] })); +}); + +afterAll(async () => { + await client.close(); +}); + +test('add', async () => { + const result = await client.callTool({ name: 'add', arguments: { a: 2, b: 3 } }); + expect(result.structuredContent).toEqual({ sum: 5 }); +}); +``` From b70461eb9dcee1568116fc44c83fc69cc29b69ad Mon Sep 17 00:00:00 2001 From: Burak Kaygusuz <17873574+burakkaygusuz@users.noreply.github.com> Date: Sat, 28 Nov 2026 15:56:06 +0300 Subject: [PATCH 4/5] docs(typescript-mcp-development): update plugin to 2.0.0 for MCP TypeScript SDK 2.x --- plugins/typescript-mcp-development/README.md | 14 +++++++------- plugins/typescript-mcp-development/plugin.json | 5 +++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/plugins/typescript-mcp-development/README.md b/plugins/typescript-mcp-development/README.md index 4e26721d9b..d79823bfdc 100644 --- a/plugins/typescript-mcp-development/README.md +++ b/plugins/typescript-mcp-development/README.md @@ -1,6 +1,6 @@ # TypeScript MCP Server Development Plugin -Complete toolkit for building Model Context Protocol (MCP) servers in TypeScript/Node.js using the official SDK. Includes instructions for best practices, a prompt for generating servers, and an expert chat mode for guidance. +Build Model Context Protocol (MCP) servers in TypeScript with the official MCP TypeScript SDK 2.x. The plugin includes a skill that generates a server project and an expert agent for guidance. ## Installation @@ -13,15 +13,15 @@ copilot plugin install typescript-mcp-development@awesome-copilot ### Commands (Slash Commands) -| Command | Description | -|---------|-------------| -| `/typescript-mcp-development:typescript-mcp-server-generator` | Generate a complete MCP server project in TypeScript with tools, resources, and proper configuration | +| Command | Description | +| ------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | +| `/typescript-mcp-development:typescript-mcp-server-generator` | Generate a Node.js project for an MCP server in TypeScript with the MCP TypeScript SDK 2.x, Vitest tests, and client configuration | ### Agents -| Agent | Description | -|-------|-------------| -| `typescript-mcp-expert` | Expert assistant for developing Model Context Protocol (MCP) servers in TypeScript | +| Agent | Description | +| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------- | +| `typescript-mcp-expert` | Expert assistant that helps developers build Model Context Protocol (MCP) servers in TypeScript with the MCP TypeScript SDK 2.x | ## Source diff --git a/plugins/typescript-mcp-development/plugin.json b/plugins/typescript-mcp-development/plugin.json index 5711205e84..925eb19487 100644 --- a/plugins/typescript-mcp-development/plugin.json +++ b/plugins/typescript-mcp-development/plugin.json @@ -1,8 +1,8 @@ { "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json", "name": "typescript-mcp-development", - "description": "Complete toolkit for building Model Context Protocol (MCP) servers in TypeScript/Node.js using the official SDK. Includes instructions for best practices, a prompt for generating servers, and an expert chat mode for guidance.", - "version": "1.0.0", + "description": "Build Model Context Protocol (MCP) servers in TypeScript with the official MCP TypeScript SDK 2.x. The plugin includes a skill that generates a server project and an expert agent for guidance.", + "version": "2.0.0", "author": { "name": "Awesome Copilot Community" }, @@ -12,6 +12,7 @@ "typescript", "mcp", "model-context-protocol", + "mcp-typescript-sdk", "nodejs", "server-development" ], From e92bf954006ed8b5f50fdb911e65e45dbdafee5f Mon Sep 17 00:00:00 2001 From: Burak Kaygusuz <17873574+burakkaygusuz@users.noreply.github.com> Date: Sat, 28 Nov 2026 15:56:06 +0300 Subject: [PATCH 5/5] docs(typescript-mcp-development): regenerate catalog files --- .github/plugin/marketplace.json | 4 ++-- docs/README.agents.md | 2 +- docs/README.instructions.md | 2 +- docs/README.plugins.md | 2 +- docs/README.skills.md | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/plugin/marketplace.json b/.github/plugin/marketplace.json index 2a1b49b006..aa37b5d33f 100644 --- a/.github/plugin/marketplace.json +++ b/.github/plugin/marketplace.json @@ -3480,8 +3480,8 @@ { "name": "typescript-mcp-development", "source": "plugins/typescript-mcp-development", - "description": "Complete toolkit for building Model Context Protocol (MCP) servers in TypeScript/Node.js using the official SDK. Includes instructions for best practices, a prompt for generating servers, and an expert chat mode for guidance.", - "version": "1.0.0" + "description": "Build Model Context Protocol (MCP) servers in TypeScript with the official MCP TypeScript SDK 2.x. The plugin includes a skill that generates a server project and an expert agent for guidance.", + "version": "2.0.0" }, { "name": "typespec-m365-copilot", diff --git a/docs/README.agents.md b/docs/README.agents.md index e8f3d18c65..dbb8264bf9 100644 --- a/docs/README.agents.md +++ b/docs/README.agents.md @@ -234,7 +234,7 @@ See [CONTRIBUTING.md](../CONTRIBUTING.md#adding-agents) for guidelines on how to | [Terratest Module Testing](../agents/terratest-module-testing.agent.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/agent?url=vscode%3Achat-agent%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fagents%2Fterratest-module-testing.agent.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/agent?url=vscode-insiders%3Achat-agent%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fagents%2Fterratest-module-testing.agent.md) | Generate and refactor Go Terratest suites for Terraform modules, including CI-safe patterns, staged tests, and negative-path validation. | | [Thinking Beast Mode](../agents/Thinking-Beast-Mode.agent.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/agent?url=vscode%3Achat-agent%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fagents%2FThinking-Beast-Mode.agent.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/agent?url=vscode-insiders%3Achat-agent%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fagents%2FThinking-Beast-Mode.agent.md) | A transcendent coding agent with quantum cognitive architecture, adversarial intelligence, and unrestricted creative freedom. | | [Trojan Skill Hunter](../agents/trojan-skill-hunter.agent.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/agent?url=vscode%3Achat-agent%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fagents%2Ftrojan-skill-hunter.agent.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/agent?url=vscode-insiders%3Achat-agent%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fagents%2Ftrojan-skill-hunter.agent.md) | Audits agent, skill, instruction, hook, and MCP-config contributions for hidden prompt injection, tool poisoning, unicode steganography, and excessive-agency red flags before they are merged, installed, or trusted — mapped to the OWASP Top 10 for LLM Applications and real-world MCP attack research. | -| [TypeScript MCP Server Expert](../agents/typescript-mcp-expert.agent.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/agent?url=vscode%3Achat-agent%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fagents%2Ftypescript-mcp-expert.agent.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/agent?url=vscode-insiders%3Achat-agent%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fagents%2Ftypescript-mcp-expert.agent.md) | Expert assistant for developing Model Context Protocol (MCP) servers in TypeScript | +| [TypeScript MCP Expert](../agents/typescript-mcp-expert.agent.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/agent?url=vscode%3Achat-agent%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fagents%2Ftypescript-mcp-expert.agent.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/agent?url=vscode-insiders%3Achat-agent%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fagents%2Ftypescript-mcp-expert.agent.md) | Expert assistant that helps developers build Model Context Protocol (MCP) servers in TypeScript with the MCP TypeScript SDK 2.x | | [Ultimate Transparent Thinking Beast Mode](../agents/Ultimate-Transparent-Thinking-Beast-Mode.agent.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/agent?url=vscode%3Achat-agent%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fagents%2FUltimate-Transparent-Thinking-Beast-Mode.agent.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/agent?url=vscode-insiders%3Achat-agent%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fagents%2FUltimate-Transparent-Thinking-Beast-Mode.agent.md) | Ultimate Transparent Thinking Beast Mode | | [Universal Janitor](../agents/janitor.agent.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/agent?url=vscode%3Achat-agent%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fagents%2Fjanitor.agent.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/agent?url=vscode-insiders%3Achat-agent%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fagents%2Fjanitor.agent.md) | Perform janitorial tasks on any codebase including cleanup, simplification, and tech debt remediation. | | [Universal PR Comment Addresser](../agents/address-comments.agent.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/agent?url=vscode%3Achat-agent%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fagents%2Faddress-comments.agent.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/agent?url=vscode-insiders%3Achat-agent%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fagents%2Faddress-comments.agent.md) | Address PR comments | diff --git a/docs/README.instructions.md b/docs/README.instructions.md index f8e18b680e..85f7fabc93 100644 --- a/docs/README.instructions.md +++ b/docs/README.instructions.md @@ -205,7 +205,7 @@ See [CONTRIBUTING.md](../CONTRIBUTING.md#adding-instructions) for guidelines on | [TaskSync V5 Protocol](../instructions/tasksync.instructions.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Ftasksync.instructions.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Ftasksync.instructions.md) | TaskSync V5 - Allows you to give the agent new instructions or feedback after completing a task using terminal while agent is running. | | [Terraform Conventions](../instructions/terraform.instructions.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fterraform.instructions.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fterraform.instructions.md) | Terraform Conventions and Guidelines | | [Terraform on SAP BTP – Best Practices & Conventions](../instructions/terraform-sap-btp.instructions.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fterraform-sap-btp.instructions.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fterraform-sap-btp.instructions.md) | Terraform conventions and guidelines for SAP Business Technology Platform (SAP BTP). | -| [TypeScript MCP Server Development](../instructions/typescript-mcp-server.instructions.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Ftypescript-mcp-server.instructions.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Ftypescript-mcp-server.instructions.md) | Instructions for building Model Context Protocol (MCP) servers using the TypeScript SDK | +| [TypeScript MCP Server Development](../instructions/typescript-mcp-server.instructions.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Ftypescript-mcp-server.instructions.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Ftypescript-mcp-server.instructions.md) | Instructions to build Model Context Protocol (MCP) servers in TypeScript with the MCP TypeScript SDK 2.x | | [TypeSpec for Microsoft 365 Copilot Development Guidelines](../instructions/typespec-m365-copilot.instructions.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Ftypespec-m365-copilot.instructions.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Ftypespec-m365-copilot.instructions.md) | Guidelines and best practices for building TypeSpec-based declarative agents and API plugins for Microsoft 365 Copilot | | [Update Code from Shorthand](../instructions/update-code-from-shorthand.instructions.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fupdate-code-from-shorthand.instructions.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fupdate-code-from-shorthand.instructions.md) | Shorthand code will be in the file provided from the prompt or raw data in the prompt, and will be used to update the code file when the prompt has the text `UPDATE CODE FROM SHORTHAND`. | | [Update Documentation on Code Change](../instructions/update-docs-on-code-change.instructions.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fupdate-docs-on-code-change.instructions.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fupdate-docs-on-code-change.instructions.md) | Automatically update README.md and documentation files when application code changes require documentation updates | diff --git a/docs/README.plugins.md b/docs/README.plugins.md index a67d9845ca..43e380489d 100644 --- a/docs/README.plugins.md +++ b/docs/README.plugins.md @@ -134,7 +134,7 @@ See [CONTRIBUTING.md](../CONTRIBUTING.md#adding-plugins) for guidelines on how t | [the-workshop](../plugins/the-workshop/README.md) | Stop being the switchboard between your AI agents — direct a team. The Workshop puts long-running AI agents (desks) in the same room, on the same work, each with its own memory and history, sharing one workspace so you direct the work instead of relaying it. | 7 items | multi-agent, coordination, desks, persistent-memory, agent-signals, developer-experience | | [tiny-tool-town-submitter](../plugins/tiny-tool-town-submitter/README.md) | Inspect a repository, improve Tiny Tool Town readiness, submit its listing issue, and launch remediation work. | 1 items | github-issues, open-source, project-readiness, repository-analysis, submission-workflow, tiny-tool-town | | [token-pacman](../plugins/token-pacman/README.md) | Visualizes live session AI-credit usage as a Pac-Man board with pellets, ghosts, fruit milestones, and game-over limits. | 1 items | ai-credits, copilot-canvas, interactive-canvas, pac-man, quota-tracking, session-usage | -| [typescript-mcp-development](../plugins/typescript-mcp-development/README.md) | Complete toolkit for building Model Context Protocol (MCP) servers in TypeScript/Node.js using the official SDK. Includes instructions for best practices, a prompt for generating servers, and an expert chat mode for guidance. | 2 items | typescript, mcp, model-context-protocol, nodejs, server-development | +| [typescript-mcp-development](../plugins/typescript-mcp-development/README.md) | Build Model Context Protocol (MCP) servers in TypeScript with the official MCP TypeScript SDK 2.x. The plugin includes a skill that generates a server project and an expert agent for guidance. | 2 items | typescript, mcp, model-context-protocol, mcp-typescript-sdk, nodejs, server-development | | [typespec-m365-copilot](../plugins/typespec-m365-copilot/README.md) | Comprehensive collection of prompts, instructions, and resources for building declarative agents and API plugins using TypeSpec for Microsoft 365 Copilot extensibility. | 3 items | typespec, m365-copilot, declarative-agents, api-plugins, agent-development, microsoft-365 | | [uizze](../plugins/uizze/README.md) | Build product-specific interfaces with a focused UIZZE workflow, optional real-screen evidence, and a practical finish check. | 1 items | ui, design, frontend, ios, web, design-review, quality-gate | | [visual-pr](../plugins/visual-pr/README.md) | Capture, annotate, and embed screenshots and animated GIF demos in pull request descriptions. Includes Playwright-based UI capture, PIL image annotations, PR embedding workflows for GitHub and Azure DevOps, and screen recording with variable timing. | 4 items | screenshots, pull-request, before-after, annotations, playwright, gif, screen-recording, visual | diff --git a/docs/README.skills.md b/docs/README.skills.md index 2e7e1853bf..8107fe5bb9 100644 --- a/docs/README.skills.md +++ b/docs/README.skills.md @@ -462,7 +462,7 @@ See [CONTRIBUTING.md](../CONTRIBUTING.md#adding-skills) for guidelines on how to | [tm7-threat-model](../skills/tm7-threat-model/SKILL.md)
`gh skills install github/awesome-copilot tm7-threat-model` | Creates valid Microsoft Threat Modeling Tool (.tm7) files compatible with the Microsoft Threat Modeling Tool v7.3+. Use this skill whenever asked to create, generate, or modify a .tm7 threat model file, or when performing STRIDE threat modeling that should output a .tm7 file that opens cleanly in the Microsoft Threat Modeling Tool. | `assets/example-minimal.tm7` | | [transloadit-media-processing](../skills/transloadit-media-processing/SKILL.md)
`gh skills install github/awesome-copilot transloadit-media-processing` | Process media files (video, audio, images, documents) using Transloadit. Use when asked to encode video to HLS/MP4, generate thumbnails, resize or watermark images, extract audio, concatenate clips, add subtitles, OCR documents, or run any media processing pipeline. Covers 86+ processing robots for file transformation at scale. | None | | [tugboat](../skills/tugboat/SKILL.md)
`gh skills install github/awesome-copilot tugboat` | Anxiety-aware, evidence-driven collaboration for stalled or high-stakes work when a user says uncertainty, repeated setbacks, or lack of visible progress is causing significant anxiety or distress. Use immediately when explicitly invoked; when this fit is only inferred from the user's own account, ask permission before applying it. Preserve the user's ideal and turn grounded perspective-taking into persistent, bounded problem solving. Do not use to diagnose, provide therapy, manufacture certainty, or lower goals for reassurance. | None | -| [typescript-mcp-server-generator](../skills/typescript-mcp-server-generator/SKILL.md)
`gh skills install github/awesome-copilot typescript-mcp-server-generator` | Generate a complete MCP server project in TypeScript using the MCP TypeScript SDK v2 (@modelcontextprotocol/server) with tools, resources, and proper configuration | None | +| [typescript-mcp-server-generator](../skills/typescript-mcp-server-generator/SKILL.md)
`gh skills install github/awesome-copilot typescript-mcp-server-generator` | Use this skill when the user wants to create a new Model Context Protocol (MCP) server in TypeScript or Node.js. Also use it to expose TypeScript code, an API, or a database to AI clients as MCP tools. The skill makes an npm project with the MCP TypeScript SDK 2.x, Vitest tests, and client configuration. Do not use it for an MCP client or for a server in another language. | `references/streamable-http.md` | | [typespec-api-operations](../skills/typespec-api-operations/SKILL.md)
`gh skills install github/awesome-copilot typespec-api-operations` | Add GET, POST, PATCH, and DELETE operations to a TypeSpec API plugin with proper routing, parameters, and adaptive cards | None | | [typespec-create-agent](../skills/typespec-create-agent/SKILL.md)
`gh skills install github/awesome-copilot typespec-create-agent` | Generate a complete TypeSpec declarative agent with instructions, capabilities, and conversation starters for Microsoft 365 Copilot | None | | [typespec-create-api-plugin](../skills/typespec-create-api-plugin/SKILL.md)
`gh skills install github/awesome-copilot typespec-create-api-plugin` | Generate a TypeSpec API plugin with REST operations, authentication, and Adaptive Cards for Microsoft 365 Copilot | None |