使用说明
MCP终端
一种用于模型上下文协议(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工具。LLM可以与MCP服务器工具交互,以帮助回答您的问题并执行操作。
您可以指定要使用的服务器:
mcp-terminal chat -s local-stdio
服务器类型
聊天命令支持两种类型的服务器配置:
- 基于URL的服务器 -配置了URL的服务器将通过HTTP/SSE连接
- 基于命令的服务器 -只有命令的服务器将自动启动并使用stdio传输
需求
要使用聊天功能,您需要:
- 一个OpenAI API密钥(设置为
OPENAI_API_KEY环境变量或.env文件) - 已配置的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
