
typescript mcp workshop
一个基于 TypeScript 的 Model Context Protocol (MCP) 实践工作坊,通过示例展示动态工具集成。
Repository Info
About This Server
一个基于 TypeScript 的 Model Context Protocol (MCP) 实践工作坊,通过示例展示动态工具集成。
Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.
Documentation
TypeScript MCP Workshop: Complete Guide to Local and Remote Servers
Model Context Protocol (MCP) is an open protocol that enables language models and AI systems to dynamically discover, describe, and interact with external tools, APIs, and services in a standardised way. MCP allows for flexible, real-time tool integration, making it possible for AI to adapt to new capabilities without redeployment.
This workshop demonstrates both local and remote MCP implementations using TypeScript, progressing from basic concepts to production-ready servers that work with Claude, ChatGPT, and other MCP clients.
Prerequisites
The workshop requires the following tools to be installed:
- Node.js v22 or higher
- pnpm (Package manager)
- TypeScript configuration (provided in the repo)
LLM Configuration
You can use the examples with ollama and models like llama3.2:latest, but for better results use frontier models from OpenAI, Anthropic, Google, Mistral, or Groq.
Update the model variable in src/model.ts to configure your preferred model.
Setup and Environment Check
Run the setup script to verify your environment is properly configured:
pnpm setup
This will run the setup script located at scripts/setup.js. You can review or run this script directly if you want to see exactly what is being checked or to troubleshoot your environment.
The setup script will:
- Check Node.js version (v22+ required)
- Verify package manager installation
- Check Ollama installation and required models
- Validate TypeScript configuration
- Test network connectivity for remote examples
Examples Overview
Part I: Local MCP Servers
These examples demonstrate MCP servers running locally, perfect for learning core concepts and local AI workflows.
01 - Tools Only
A dynamic calculator server that demonstrates how to add, remove, and discover tools at runtime using MCP. Learn how to build and test tools that can be updated live, with no server restart required.
# Run server
pnpm example:server:01
# Run client
pnpm example:client:01
02 - Resources: Give AI Access to Real Data
Serve live data, files, and documentation to AI using MCP resources. This example shows how to expose system metrics, logs, configurations, and more, in multiple formats (JSON, CSV, HTML, images).
# Run server
pnpm example:server:02
# Run client
pnpm example:client:02
03 - Prompts: Consistent AI Results
Build a library of reusable prompt templates for consistent, high-quality AI results. See how to generate code reviews, team discussions, explanations, and more, using dynamic prompt construction.
# Run server
pnpm example:server:03
# Run client
pnpm example:client:03
04 - Standard I/O and Filesystem
Use the stdio protocol to enable local MCP servers to access your filesystem. Expose tools for listing directories and reading files, and see how local AI tools can interact with your real environment.
# Run server
pnpm example:server:04
# Run client
pnpm example:client:04
05 - Multi-Server Architecture
Compose multiple MCP servers (e.g., user and payment services) and combine their tools in a single client workflow. Demonstrates modular, scalable AI architectures.
# Run both user and payment servers
pnpm example:server:05
# Run client
pnpm example:client:05
06 - Authentication with API Keys
Implement API key authentication and session management in MCP servers. Learn how to restrict access, personalize responses, and audit user actions for secure, stateful AI workflows.
# Run server
pnpm example:server:06
# Run client with API key
pnpm example:client:06 -- --api-key your-key-here
07 - Playwright Demo: Browser Automation
Automate browsers using Playwright and MCP. This demo shows how to expose Playwright's browser automation capabilities as MCP tools, enabling an AI to navigate websites, fill forms, scrape data, and take screenshots.
# Run client
pnpm example:client:07
Part II: Remote MCP Servers (Production-Ready)
These examples demonstrate remote MCP servers that work with Claude, ChatGPT, and other MCP clients over HTTP, including all production requirements.
08 - Remote Server Fundamentals
Learn the fundamental differences between local and remote MCP servers. Implement your first HTTP-based MCP server with proper transport handling, session management, and basic error handling.
Key Concepts: HTTP transports, session IDs, JSON-RPC over HTTP, basic server setup
# Run remote server
pnpm example:server:08
# Test with MCP Inspector or curl
pnpm inspect:08
09 - OAuth 2.1 Authentication
Implement complete OAuth 2.1 authentication with PKCE flow as required by the MCP specification. Includes all discovery endpoints, client registration, and secure token handling.
Key Concepts: OAuth 2.1, PKCE flow, .well-known endpoints, client registration, token validation
# Run OAuth-enabled server
pnpm example:server:09
# Test OAuth flow
pnpm example:client:09
Debugging with MCP Inspector
The MCP Inspector is a powerful tool for interactively testing and debugging your MCP servers:
# Inspect any example server
pnpm inspect
# Inspect specific examples
pnpm inspect:01 # Local tools-only
Next Steps
- Start with Local Examples (01-07) if you're new to MCP
- Move to Remote Examples (08-09) for production use cases
Each example builds on previous concepts while introducing new functionality, ensuring you understand both the fundamentals and advanced production requirements.
For detailed information about each example, see the individual README files in each directory.
Quick Start
Clone the repository
git clone https://github.com/jagreehal/typescript-mcp-workshopInstall dependencies
cd typescript-mcp-workshop
npm installFollow the documentation
Check the repository's README.md file for specific installation and usage instructions.
Repository Details
Recommended MCP Servers
Discord MCP
Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.
Knit MCP
Connect AI agents to 200+ SaaS applications and automate workflows.
Apify MCP Server
Deploy and interact with Apify actors for web scraping and data extraction.
BrowserStack MCP
BrowserStack MCP Server for automated testing across multiple browsers.
Zapier MCP
A Zapier server that provides automation capabilities for various apps.