模型上下文协议服务器

MCP是一个标准化协议,用于AI应用程序与各种数据源和工具的标准连接,类似于AI模型的USB-C端口。

  • by alesion30
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 Alesion30/my-mcp-server

使用说明

我的MCP服务器

MCP(模型上下文协议)

MCP应用程序LLM中描述的场景,使用以下步骤创建明细表,以便在概念设计中分析体量的体积。这是AI应用程序USB-C像端口一样AI允许以标准的方式连接模型和各种数据源和工具。

flowchart LR
  User(fa:fa-user User)
  Client["""
  Host with MCP Client
  (Claude, IDEs, Tools)
  """]

  Server1["MCP Server A"]
  Server2["MCP Server B"]
  Server3["MCP Server C"]

  DB1["Local Data Source A"]
  DB2["Local Data Source B"]
  Services["Remote Services"]

  subgraph Local Computer
  User <--> Client
  Client <--> |MCP Protocol| Server1
  Client <--> |MCP Protocol| Server2
  Client <--> |MCP Protocol| Server3

  Server1 <--> DB1
  Server2 <--> DB2
  end

  subgraph Internet
  Server2 <--> |Web APIs| Services
  Server3 <--> |Web APIs| Services
  end

参考: https://modelcontextprotocol.io/introduction

【类似概念】Function Calling

flowchart LR
  User(fa:fa-user User)
  Server["Application Server"]
  OpenAI["OpenAI API"]

  Function1["Function A on Server"]
  Function2["Function B on Server"]
  Function3["Function C on Server"]
  DB["Local Data Source"]
  Services["Remote Services"]

  subgraph Local Computer
  User <--> Server
  Server <--> Function1
  Server <--> Function2
  Server <--> Function3
  Function1 <--> DB
  Function2 <--> DB
  end

  subgraph "Internet(OpenAI)"
  Server --> |prompt| OpenAI
  OpenAI --> |response with function calls| Server
  end

  subgraph Internet
  Function2 <--> |Web APIs| Services
  Function3 <--> |Web APIs| Services
  end

参考: https://platform.openai.com/docs/guides/function-calling

入门指南

1. Claude Desktop下载,下载

https://claude.ai/download

2. Custom MCP构建服务器

$ npm install
$ npm run build

# build/main.jsのフルパスを表示する
$ find `pwd` -maxdepth 2 -name main.js

3. Claude Desktop在工作空间的边缘MCP注册服务器

[!注意] 以下macOS版的做法。其他OS关于,关于正式文档来修改标记元素的显示属性。

$ vi ~/Library/Application\ Support/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "myMcp": {
      // NOTE: nodeのフルパスを指定(`$ which node`)
      "command": "node",
      // NOTE: build/main.jsのフルパスを指定
      "args": ["xxx/my-mcp-server/build/main.js"]
    }
  }
}

4. Claude Desktop单击功能区上MCP确认服务器已注册

Claude Desktop重新启动MCP确认服务器已注册

试着问了旧金山的天气MCP从服务器获取和生成天气预报信息AI的信息中加入了天气的信息。

(参考)MCP没有服务器

参考链接

  • https://www.anthropic.com/news/model-context-protocol
  • https://modelcontextprotocol.io/quickstart/server