🛠️ Simple MCP Example with Claude and a Local JSON HTTP Server

🛠️ Simple MCP Example with Claude and a Local JSON HTTP Server

Okay, here's a translation of "Simple MCP server using Claude to interact with a local JSON server" into Chinese, along with a few options depending on the nuance you want to convey: **Option 1 (Most Literal and Common):** * **使用 Claude 与本地 JSON 服务器交互的简单 MCP 服务器** * (Shǐyòng Claude yǔ běndì JSON fúwùqì jiāohù de jiǎndān MCP fúwùqì) This is a direct translation. It's clear and understandable. **Option 2 (Slightly More Natural Flow):** * **一个简单的 MCP 服务器,使用 Claude 来与本地 JSON 服务器进行交互** * (Yī gè jiǎndān de MCP fúwùqì, shǐyòng Claude lái yǔ běndì JSON fúwùqì jìnxíng jiāohù) This adds "一个" (yī gè - "a/an") at the beginning and "来进行" (lái jìnxíng - "to perform") before "交互" (jiāohù - "interact"). It makes the sentence flow a bit more naturally in Chinese. **Option 3 (Emphasizing the Purpose):** * **一个简单的 MCP 服务器,用于使用 Claude 与本地 JSON 服务器交互** * (Yī gè jiǎndān de MCP fúwùqì, yòng yú shǐyòng Claude yǔ běndì JSON fúwùqì jiāohù) This uses "用于" (yòng yú - "used for") to explicitly state the purpose of the MCP server. **Breakdown of the terms:** * **Simple:** 简单的 (jiǎndān de) * **MCP server:** MCP 服务器 (MCP fúwùqì) (MCP is usually kept as is) * **using Claude:** 使用 Claude (shǐyòng Claude) * **to interact:** 交互 (jiāohù) or 进行交互 (jìnxíng jiāohù) * **with:** 与 (yǔ) * **a local JSON server:** 本地 JSON 服务器 (běndì JSON fúwùqì) **Which option is best?** Option 1 is perfectly acceptable and the most straightforward. Option 2 is slightly more natural-sounding. Option 3 is good if you want to emphasize the purpose. Choose the one that best fits the context of where you're using the translation.

sunmer

开发者工具
访问服务器

README

🛠️ 使用 Claude 和本地 JSON HTTP 服务器的简单 MCP 示例

本指南将引导你完成一个基本设置,你将使用 Claude (MacOS 桌面版) 通过 MCP (模型-计算机协议) 与本地 模拟 JSON 服务器 进行交互。


🧰 前提条件

  • 已安装 Node.js
  • Claude for MacOS (从 Anthropic 下载)
  • 对本地服务器和 Claude MCP 工具的工作方式有基本的了解

🚀 逐步设置

1. 安装依赖项

在你的项目根目录中,安装所需的包:

npm install
npm run mock-api
npm run mcp-server

编辑 claude_desktop_config.json 文件(通常位于 ~/.claude/ 或应用程序的内部配置文件夹中),并添加你的 MCP 服务器配置:

{
  "mcpServers": {
    "json-chat": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-example/dist/index.js"]
    }
  }
}
  • 重启 Claude

  • 重启后,你应该会在 Claude 的输入栏下方看到两个新的 MCP 工具,每个工具都标有一个 🛠️ 锤子图标:

  • 尝试使用类似以下的提示词来提示 Claude:

"get all posts"

"insert a post with id 500, title "created by claude" and views 123"

Claude 将使用你配置的 MCP 工具向你的本地模拟服务器发送实际请求。

请确保在提示 Claude 时,你正在运行 JSON 服务器和 MCP 服务器。

测试

运行

npx @modelcontextprotocol/inspector node build/index.js

然后,你应该在 http://127.0.0.1:6274/#resources 看到所有可用的资源。

推荐服务器

Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
MCP Package Docs Server

MCP Package Docs Server

促进大型语言模型高效访问和获取 Go、Python 和 NPM 包的结构化文档,通过多语言支持和性能优化来增强软件开发。

精选
本地
TypeScript
Claude Code MCP

Claude Code MCP

一个实现了 Claude Code 作为模型上下文协议(Model Context Protocol, MCP)服务器的方案,它可以通过标准化的 MCP 接口来使用 Claude 的软件工程能力(代码生成、编辑、审查和文件操作)。

精选
本地
JavaScript
@kazuph/mcp-taskmanager

@kazuph/mcp-taskmanager

用于任务管理的模型上下文协议服务器。它允许 Claude Desktop(或任何 MCP 客户端)在基于队列的系统中管理和执行任务。

精选
本地
JavaScript
mermaid-mcp-server

mermaid-mcp-server

一个模型上下文协议 (MCP) 服务器,用于将 Mermaid 图表转换为 PNG 图像。

精选
JavaScript
Jira-Context-MCP

Jira-Context-MCP

MCP 服务器向 AI 编码助手(如 Cursor)提供 Jira 工单信息。

精选
TypeScript
Linear MCP Server

Linear MCP Server

一个模型上下文协议(Model Context Protocol)服务器,它与 Linear 的问题跟踪系统集成,允许大型语言模型(LLM)通过自然语言交互来创建、更新、搜索和评论 Linear 问题。

精选
JavaScript
Sequential Thinking MCP Server

Sequential Thinking MCP Server

这个服务器通过将复杂问题分解为顺序步骤来促进结构化的问题解决,支持修订,并通过完整的 MCP 集成来实现多条解决方案路径。

精选
Python
Curri MCP Server

Curri MCP Server

通过管理文本笔记、提供笔记创建工具以及使用结构化提示生成摘要,从而实现与 Curri API 的交互。

官方
本地
JavaScript