Skip to main content
Glama

MCP Chat

MCP Chat 是一个命令行界面应用程序,通过 Anthropic API 实现与 AI 模型的交互式聊天功能。该应用程序支持文档检索、基于命令的提示词,以及通过 MCP(模型控制协议)架构实现的可扩展工具集成。

前提条件

  • Python 3.9+

  • Anthropic API 密钥

Related MCP server: mcp_starter_project

设置

步骤 1:配置环境变量

  1. 在项目根目录创建或编辑 .env 文件,并确认以下变量已正确设置:

ANTHROPIC_API_KEY=""  # Enter your Anthropic API secret key

步骤 2:安装依赖

选项 1:使用 uv 进行设置(推荐)

uv 是一个快速的 Python 包安装器和解析器。

  1. 如果尚未安装 uv,请先安装 uv:

pip install uv
  1. 创建并激活虚拟环境:

uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  1. 安装依赖:

uv pip install -e .
  1. 运行项目

uv run main.py

选项 2:不使用 uv 进行设置

  1. 创建并激活虚拟环境:

python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  1. 安装依赖:

pip install anthropic python-dotenv prompt-toolkit "mcp[cli]==1.8.0"
  1. 运行项目

python main.py

使用方法

基本交互

只需输入你的消息并按回车键,即可与模型聊天。

文档检索

使用 @ 符号后跟文档 ID,即可在查询中包含文档内容:

> Tell me about @deposition.md

命令

使用 / 前缀执行 MCP 服务器中定义的命令:

> /summarize deposition.md

命令会在你按下 Tab 键时自动补全。

开发

添加新文档

编辑 mcp_server.py 文件,将新文档添加到 docs 字典中。

实现 MCP 功能

要完整实现 MCP 功能:

  1. 完成 mcp_server.py 中所有的 TODO

  2. 实现 mcp_client.py 中缺失的功能

Lint 与类型检查

目前没有实现任何 lint 或类型检查。

Available Tools

2 tools
edit_documentA

Edit a document by replacing a string in the documents content with a new string

Inputs: doc_id (required), new_str (required), old_str (required).

read_doc_contentsA

Read the contents of a document and return it as a string.

Inputs: doc_id (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 2 tools

    Disambiguation5/5

    The two tools are clearly distinct: one reads document contents, the other modifies them. There is no overlap or ambiguity between the operations.

    Naming Consistency4/5

    Both tools use a verb_noun pattern and snake_case, but one uses 'doc_contents' and the other uses 'document', which is a minor inconsistency. A more consistent pair would be read_document/edit_document.

    Tool Count3/5

    Two tools is a thin surface and falls at the borderline for a useful server. The tools are focused, but the count feels minimal for a standalone document-related MCP server.

    Completeness2/5

    The tool surface covers reading and editing documents but lacks create, delete, list, and search capabilities. This leaves significant lifecycle gaps that agents may need to work around.

    Related MCP Connectors

    Related MCP Servers