Token导航 LogoToken导航TokenDH.com
MCP Client Example logo
AI代理未说明官方级别未说明来源级核验

MCP Client Example

MCP Server

This is a sample CLI chat application for an AI assistant using the Anthropic API in conjunction with an MCP client and MCP server.

工具数

2

提示词数

0

GitHub Stars

0

资源数

0
TypeScript命令行工具AI代理

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

t-shiratori

提供方

t-shiratori

最后核验

2026/5/18 02:51

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

Mcp客户端示例

这是一个用于AI助手的示例CLI聊天应用程序,使用Anthropic API与MCP客户端和MCP服务器。

参考: 面向客户端开发人员-模型上下文协议

无烟煤API: 初始设置-Anthropic 信息-人物

系统图

序列图

sequenceDiagram
    participant User
    participant MCPClient
    participant AnthropicAPI
    participant MCPServer

    User->>MCPClient: Run
    MCPClient->>MCPServer: Connect and get tool info
    MCPServer-->>MCPClient: Tool info

    loop Chat loop (until 'quit' is entered)
        User->>MCPClient: Enter query
        MCPClient->>AnthropicAPI: Send query
        AnthropicAPI-->>MCPClient: AI response

        alt When tool usage is required
            MCPClient->>MCPServer: Call tool
            MCPServer-->>MCPClient: Tool execution result
            MCPClient->>AnthropicAPI: Send query again including tool result
            AnthropicAPI-->>MCPClient: Final response
        end

        MCPClient-->>User: Display response
    end

    User->>MCPClient: Enter 'quit'
    MCPClient->>MCPServer: Disconnect
    MCPClient-->>User: Exit

设置

pnpm install

.env

ANTHROPIC_API_KEY=your-api-key
MCP_SERVER_SCRIPT_PATH=/path/to/mcp-server.js

构建

pnpm build

pnpm start

输出示例

使用此mcp服务器 https://github.com/t-shiratori/time-tools-mcp-server


mcp-client-example $ pnpm start

> mcp-client-example@1.0.0 start /path/to/mcp-client-example
> node build/index.js

Example MCP Server running on stdio
Connected to server with tools: [ 'get_current_date_time', 'get_elapsed_time' ]

MCP Client Started!
Type your queries or 'quit' to exit.

🖌 Query: Hello

Hello! I'm here to assist you. I can help you with tasks related to date and time, such as getting the current date and time or calculating the elapsed time between two dates.

Is there something specific you'd like to know about dates or times today?

🖌 Query: What time is it?

I can check the current date and time for you.
[Calling tool get_current_date_time with args {}]
Based on the given timestamp, the time is 10:37:19 AM on May 6th, 2025.

目录标签

目录标签

TypeScript命令行工具AI代理communicationAI助手本地部署聊天应用工具调用时间查询

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

2

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP