freewind-demos
MCP Serverfreewind-demospublic

typescript ai claude mcp demo

展示如何使用 Claude 的 MCP 协议实现编程控制的 TypeScript 示例项目。

Repository Info

0
Stars
0
Forks
0
Watchers
0
Issues
TypeScript
Language
-
License

About This Server

展示如何使用 Claude 的 MCP 协议实现编程控制的 TypeScript 示例项目。

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

AI Claude MCP Demo

这是一个演示如何使用Claude的MCP(Model-Controlled Programming)协议的TypeScript示例项目。

什么是MCP?

MCP(Model-Controlled Programming)是一种让AI助手能够更好地控制和执行编程任务的协议。它允许AI助手:

  1. 理解用户的编程需求
  2. 规划解决方案
  3. 执行必要的代码操作
  4. 验证执行结果

虽然这个示例使用Claude作为实现,但MCP协议的思想是通用的,可以应用于其他AI模型。

项目结构

.
├── src/
│   ├── types.ts       # MCP相关的类型定义
│   ├── mcp-client.ts  # MCP客户端实现
│   ├── mock-client.ts # Mock客户端(用于测试)
│   └── index.ts       # 示例代码
├── package.json
├── tsconfig.json
└── README.md

安装

npm install

使用方法

项目支持两种运行模式:

1. 使用Claude API

如果你有Claude的API密钥:

export CLAUDE_API_KEY=your-api-key
npm start

2. 使用Mock模式

如果你没有提供CLAUDE_API_KEY,项目会自动使用mock模式:

npm start

Mock模式会模拟AI助手的响应,支持基本的代码审查和重构操作。这种模式适合用来学习和测试MCP协议的工作方式。

示例说明

示例代码展示了如何:

  1. 创建MCP客户端
  2. 发送代码审查请求
  3. 接收AI助手的响应
  4. 执行AI助手建议的操作

API说明

MCPRequest

interface MCPRequest {
  type: string;      // 请求类型
  content: string;   // 请求内容
  context?: {        // 上下文信息
    language?: string;
    framework?: string;
    [key: string]: any;
  };
}

MCPResponse

interface MCPResponse {
  status: 'success' | 'error';  // 响应状态
  message: string;              // 响应消息
  actions?: MCPAction[];        // AI建议的操作
  error?: string;              // 错误信息
}

MCPAction

interface MCPAction {
  type: string;               // 操作类型
  target: string;            // 操作目标
  content: string;           // 操作内容
  params?: Record<string, any>; // 操作参数
}

注意事项

  1. 如果使用Claude API,请确保妥善保管API密钥
  2. Mock模式仅供学习和测试使用,不能替代实际的AI助手
  3. 目前这只是一个演示项目,实际使用时需要根据具体需求扩展功能
  4. 建议在使用前仔细阅读Claude的API文档

许可证

MIT

Quick Start

1

Clone the repository

git clone https://github.com/freewind-demos/typescript-ai-claude-mcp-demo
2

Install dependencies

cd typescript-ai-claude-mcp-demo
npm install
3

Follow the documentation

Check the repository's README.md file for specific installation and usage instructions.

Repository Details

Ownerfreewind-demos
Repotypescript-ai-claude-mcp-demo
LanguageTypeScript
License-
Last fetched8/10/2025

Recommended MCP Servers

💬

Discord MCP

Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.

integrationsdiscordchat
🔗

Knit MCP

Connect AI agents to 200+ SaaS applications and automate workflows.

integrationsautomationsaas
🕷️

Apify MCP Server

Deploy and interact with Apify actors for web scraping and data extraction.

apifycrawlerdata
🌐

BrowserStack MCP

BrowserStack MCP Server for automated testing across multiple browsers.

testingqabrowsers

Zapier MCP

A Zapier server that provides automation capabilities for various apps.

zapierautomation