MR
Mayur Rathi
@github
⭐ 34.1k GitHub stars

Typescript-Mcp-Server

Typescript-Mcp-Server是一款code方向的AI技能,核心价值是Instructions for building Model Context Protocol (MCP) servers using the TypeScript SDK,可用于解决开发者在code领域的实际问题,帮助用户提升效率、自动化重复任务或优化工作流。

Instructions for building Model Context Protocol (MCP) servers using the TypeScript SDK

Last verified on: 2026-05-30
mkdir -p ./skills/typescript-mcp-server && curl -sfL https://raw.githubusercontent.com/github/awesome-copilot/main/skills/typescript-mcp-server/SKILL.md -o ./skills/typescript-mcp-server/SKILL.md

Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).

Skill Content

# TypeScript MCP Server Development


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`


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


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);

Basic Server Setup (stdio)

typescript
import { McpServer } from '

🎯 Best For

  • UI designers
  • Product designers
  • Claude users
  • GitHub Copilot users
  • Software engineers

💡 Use Cases

  • Generating component mockups
  • Creating design system tokens
  • TypeScript type safety checking
  • Module refactoring

📖 How to Use This Skill

  1. 1

    Install the Skill

    Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.

  2. 2

    Load into Your AI Assistant

    Open Claude or GitHub Copilot and reference the skill. Paste the SKILL.md content or use the system prompt tab.

  3. 3

    Apply Typescript-Mcp-Server to Your Work

    Open your project in the AI assistant and ask it to apply the skill. Start with a small module to verify the output quality.

  4. 4

    Review and Refine

    Review AI suggestions before committing. Run tests, check for regressions, and iterate on the skill output.

❓ Frequently Asked Questions

Does this work with Figma?

Some design skills integrate with Figma plugins. Check the Works With section for supported tools.

Is Typescript-Mcp-Server compatible with Cursor and VS Code?

Yes — this skill works with any AI coding assistant including Cursor, VS Code with Copilot, and JetBrains IDEs.

Do I need specific dependencies for Typescript-Mcp-Server?

Check the install command and Works With section. Most code skills only require the AI assistant and your codebase.

How do I install Typescript-Mcp-Server?

Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/typescript-mcp-server/SKILL.md, ready to use.

Can I customize this skill for my team?

Absolutely. Edit the SKILL.md file to add team-specific instructions, examples, or workflows.

⚠️ Common Mistakes to Avoid

Skipping usability testing

AI-generated designs should be validated with real users before development.

Skipping validation

Always test AI-generated code changes, even for simple refactors.

Missing dependency updates

Check if the skill requires updated dependencies or new packages.

🔗 Related Skills