mcpField
M
MCP Terminal

MCP Terminal

github.com/geli2001编码 Agent1481 周前更新

关于 MCP Terminal

MCP Terminal 是用于配置和使用 MCP 服务的交互式终端客户端。它通过 stdio 或 SSE 连接多个服务,并提供可调用其工具的 AI 模型聊天功能。

主要功能

  1. 01配置多个 MCP 服务
  2. 02通过 stdio 和 SSE 连接
  3. 03切换已连接的服务
  4. 04交互式模型聊天
  5. 05在聊天中调用 MCP 工具

适用场景

  1. 01配置本地和远程服务
  2. 02为聊天会话选择服务
  3. 03通过模型聊天测试 MCP 工具

MCP 相关

作为 MCP 客户端,MCP Terminal 通过 stdio 或 SSE 连接已配置的服务,也可启动基于命令的服务,并在聊天中提供其工具。

详细介绍

MCP Terminal

一个基于终端的 Model Context Protocol (MCP) 服务交互式客户端。

安装

npm install -g mcp-terminal

功能

  • 同时连接多个 MCP 服务
  • 用于向模型发送消息的交互式终端
  • 轻松的配置管理
  • 支持 stdio 和 SSE 传输
  • 在已连接的服务之间切换

配置

在使用 MCP CLI 之前,你需要至少配置一个服务:

mcp-terminal configure

这将用默认编辑器打开一个配置文件,你可以在其中定义 MCP 服务。

配置示例:

{
  "mcpServers": {
    "local-sse": {
      "command": "npx @anthropic-ai/mcp-server@latest",
      "args": [],
      "url": "http://localhost:8765/sse"
    },
    "local-stdio": {
      "command": "npx @anthropic-ai/mcp-server@latest",
      "args": ["--stdio"]
    },
    "shopify": {
      "command": "npx",
      "args": [
        "shopify-mcp",
        "--accessToken",
        "your-shopify-access-token",
        "--domain",
        "your-store.myshopify.com"
      ]
    }
  }
}

注意服务可以配置为:

  • 同时包含 command 和 url,用于需要在本地启动但使用 SSE 传输的服务
  • 仅包含 command,用于使用 stdio 传输的服务
  • 仅包含 url,用于连接到远程服务

使用

配置 MCP 服务
mcp-terminal configure

这将用默认编辑器打开以配置 MCP 服务。

启动 MCP 服务
mcp-terminal start

这将启动已配置的 MCP 服务。你可以配置多个服务。

使用 MCP 工具与 AI 交互式聊天
mcp-terminal chat

这启动一个与 AI 模型的交互式聊天会话,该模型可以使用来自已配置服务的 MCP 工具。大模型可以与 MCP 服务工具交互,帮助回答你的问题并执行操作。

你可以指定要使用的服务:

mcp-terminal chat -s local-stdio
服务类型

chat 命令支持两种服务配置类型:

  1. 基于 URL 的服务 - 配置了 URL 的服务将通过 HTTP/SSE 连接
  2. 基于命令的服务 - 仅配置了命令的服务将自动启动并使用 stdio 传输
要求

要使用聊天功能,你需要:

  1. OpenAI API 密钥(设置为 OPENAI_API_KEY 环境变量或在 .env 文件中)
  2. 已配置的 MCP 服务(使用 mcp-terminal configure 进行配置)
使用示例
$ mcp-terminal chat
Starting chat session with LLM...
Type 'exit' or 'quit' to end the session.

Using MCP server: local-stdio
Starting MCP server: local-stdio
Server is running...
Connected to MCP server via stdio transport

You: What's the weather in New York today?
AI is thinking...
AI: I'd like to check the weather in New York for you, but I need to use a tool to get that information.

I attempted to use a weather tool, but we're currently connected via stdio transport, which doesn't allow me to directly access external tools. In a full implementation with the appropriate tools configured, I would be able to fetch real-time weather data for New York.

To get the actual weather in New York today, you could:
1. Use a different MCP server configured with HTTP/SSE transport and weather tools
2. Check a weather website or app directly
3. Ask me a different question I can answer without external tools

Can I help you with something else?

You: What is MCP?
AI is thinking...
AI: MCP stands for Model Context Protocol. It's an open standard protocol designed to connect AI language models (LLMs) like me with external tools, data sources, and APIs.

Here's what makes MCP important:

1. It allows AI models to extend their capabilities beyond their training data by accessing external tools and real-time information.

2. It provides a standardized way for developers to create tools that AI models can interact with, making integration simpler.

3. It enables AI assistants to perform actions in the real world - things like searching the web, accessing databases, running code, or interacting with services like the weather example you asked about earlier.

4. It can work through different transport methods, such as HTTP/SSE (Server-Sent Events) or stdio (standard input/output), depending on the implementation.

The MCP-terminal tool you're using right now is a client that helps manage MCP servers and facilitates communication between users, AI models, and the tools provided by those servers.

You: exit

## License

MIT

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。