Skip to main content
Glama
IDHaunter

MCP Chat

by IDHaunter

MCP Chat

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

前提条件

  • Python 3.9+

  • Anthropic API Key

Related MCP server: MCP Chat

设置

步骤 1:配置环境变量

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

CLAUDE_MODEL="claude-sonnet-4-5"
ANTHROPIC_API_KEY=""  # Enter your Anthropic API secret key

# Set to 1 if you're using uv to run the project
# Set to 0 if you're *not* using uv
USE_UV=1

步骤 2:安装依赖项

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

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

  1. 如果尚未安装,请安装 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

使用说明

基本交互

只需输入消息并按 Enter 即可与模型聊天。

文档检索

使用 @ 符号后跟文档 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

NameRequiredDescriptionDefault
doc_idYesId of the document that will be edited
new_strYesThe new text to insert in place of old text
old_strYesThe text to replace. Must match exactly, including whitespaces.

TDQS

A3.5/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It only states the operation and does not mention side effects (e.g., persistence, overwriting), failure conditions (e.g., old_str not found), or whether the edit applies to all occurrences. This is a minimal disclosure for a mutating operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no fluff. The core action and resource are front-loaded, and every word contributes to understanding the tool's purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is relatively simple (3 required string params, no output schema). The description covers the essential operation, but it omits behavioral details like what happens if old_str is not found or if multiple matches exist. For a mutating tool without annotations, this is a minor but noticeable gap.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so all parameters have descriptions in the schema. The description itself adds no new semantic detail beyond what the schema already provides; it just reiterates the replace action. This meets the baseline for high coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action (edit), the resource (a document), and the specific operation (replacing a string with a new string). This is a specific verb+resource that distinguishes it from the sibling tool read_doc_contents, which is focused on reading.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage (when you need to modify content) but provides no explicit guidance on when to use this tool versus the sibling read_doc_contents, nor does it mention any prerequisites or exclusions. The context is clear but lacks differentiation.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

read_doc_contentsA

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

NameRequiredDescriptionDefault
doc_idYesId of the document to read

TDQS

A4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the burden of behavioral disclosure. It does state the output behavior ('return it as a string'), but does not mention error handling, permissions, or what happens when the document does not exist. For a simple read operation, this is adequate but not rich.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence with no wasted words. It efficiently conveys both the operation and the return format.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

This is a simple tool with one parameter, full schema coverage, and no output schema. The description is largely complete for a read operation, especially since it explicitly states the return type. It could be slightly stronger with error or permission context, but nothing essential is missing for basic invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema already fully documents the only parameter, doc_id, as 'Id of the document to read', so schema coverage is 100%. The description adds no additional parameter meaning beyond the schema, matching the baseline score.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb and resource: 'Read the contents of a document' and explicitly notes the return type as a string. This clearly distinguishes it from the sibling 'edit_document', which implies modification rather than reading.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The verb 'Read' establishes a clear context for when this tool is appropriate, and its contrast with 'edit_document' implies read-only usage. However, it does not explicitly state when not to use it or name the alternative.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

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

  1. 2 tool updatesv0.1.0
    • First observededit_document
    • First observedread_doc_contents

TDQS

A3.6/5.0

Scored across 2 tools

Disambiguation5/5

The two tools are completely distinct: one reads document contents, the other edits them. There is no overlap or ambiguity in their purposes.

Naming Consistency4/5

Both names follow a verb_noun pattern, but one uses the abbreviation 'doc' while the other uses 'document', and one refers to 'contents' while the other uses 'document'. Minor inconsistency, but the pattern is still readable and predictable.

Tool Count3/5

With only two tools, the server feels thin for a document-related service. While each tool has a clear purpose, the low count is borderline for being considered a well-scoped set.

Completeness2/5

The server supports reading and editing but lacks create, delete, or listing capabilities. Editing is limited to string replacement, which restricts the possible workflows agents can perform.

Maintenance

ActivityStale
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers