LLM Chat MCP server
llm-chat-mcp
用于与 Continue.dev 的 config.yaml 中配置的 LLM 模型进行交互的 MCP 服务器。
功能
暴露 4 个工具,让代理可以检查你配置的模型并向其发送聊天请求:
llm_chat_list_models— 列出配置中的所有模型及其名称和 idllm_chat_get_model_params— 检查任意模型的参数(temperature、topP 等)llm_chat_get_model_prompt— 读取为模型配置的系统提示词llm_chat_send_request— 与模型聊天,可选覆盖参数或从文件加载提示词
Related MCP server: Polybrain MCP Server
安装
pip install -e .或者无需安装,直接从源码运行。
CLI 用法
python -m llm_chat_mcp --default-model "GLM-5.2-FP8"
python -m llm_chat_mcp --config /path/to/config.yaml --default-model "ModelName"
python -m llm_chat_mcp --help参数 | 描述 | 默认值 |
| config.yaml 的路径 |
|
| send_request 的默认模型 | (无) |
| 请求超时时间(秒) |
|
| 用于解析相对输出文件路径的基础目录 | (进程当前工作目录) |
| 当响应超过 | (操作系统临时目录) |
配置
每次请求都会重新读取配置 — 无需重启
认证使用 config.yaml 中每个模型条目的
apiKey如果未指定模型(既未在 CLI 中指定,也未在工具调用中指定),会返回错误并提示如何设置
llm_chat_send_request 参数
主要工具。向 LLM 发送聊天补全请求并返回响应。
输入参数
参数 | 类型 | 默认值 | 描述 |
| str | (CLI 默认值) | config.yaml 中的模型名称或 id |
| str | (无) | 要发送的提示词文本 |
| list | (无) | 文件规格列表(字符串路径或 |
| bool |
| 为每个文件行添加 |
| str | (来自配置) | 覆盖系统消息; |
| float | (来自配置) | 采样参数 |
| int/float | (来自配置) | 生成参数 |
| dict | (无) | 合并到 API 请求中的额外 body 属性 |
| bool |
| 在响应中包含推理/思考内容 |
| float | (CLI 默认值) | 单次请求的超时覆盖 |
| str | (无) | 将完整响应写入此文件(相对路径基于 |
| bool |
| 追加到 |
| int |
| 内联返回的内容最大字符数;仅当写入文件时预览才生效 |
| int |
| 当 |
响应结构
始终以 JSON 返回:
{
"content": "<preview, full content, or empty>",
"truncated": true,
"metadata": {
"model_name": "...",
"model": "...",
"elapsed_seconds": 1.23,
"request_sent": {...},
"response_headers": {...},
"response_chars": 1234,
"output_file": "...",
"auto_output_file": "...",
"created_dirs": [...],
"appended_line_start": 201,
"appended_line_end": 250
}
}输出策略
该工具根据参数和响应大小选择以下三种策略之一:
显式文件(设置了
output_file_path):完整响应写入文件。如果append=true,响应会被追加,并返回appended_line_start/appended_line_end(从 1 开始,包含两端),以便调用方可以通过extract_lines只读取追加的部分。自动文件(未设置
output_file_path,auto_file_threshold > 0,response_chars > threshold):完整响应写入--auto-output-dir(或操作系统临时目录)中自动生成的文件。文件名格式:llm_output_<YYYYMMDD_HHMMSS>_<6-char-uuid>.json。仅内联(未写入文件):完整内容在
content字段中返回。
内联预览
当写入文件时(显式或自动),content 字段包含响应的预览:
如果
inline_preview_chars > 0且len(content) > inline_preview_chars:截断的预览,带有后缀[truncated, full response in <file_path>]。如果
inline_preview_chars > 0且len(content) <= inline_preview_chars:完整内容(适合预览)。如果
inline_preview_chars == 0:content为空(文件包含完整响应)。
当未写入文件时,无论 inline_preview_chars 的值如何,完整内容都会内联返回 — 这样可以防止数据丢失。
Continue.dev 集成
添加到 .continue/mcpServers/llm-chat.yaml:
name: LLM Chat MCP server
version: 0.2.0
schema: v1
mcpServers:
- name: LLM Chat MCP server
command: python
args:
- "-m"
- "llm_chat_mcp"
- "--default-model"
- "GLM-5.2-FP8"
- "--timeout"
- "570"
- "--relative_paths_base"
- "/path/to/your/workspace"
- "--auto-output-dir"
- "/path/to/your/workspace/.continue/skills/large-tasks/tmp-outputs"
env:
PYTHONPATH: "/path/to/llm-chat-mcp"然后重新加载 Continue.dev。
项目结构
llm-chat-mcp/
├── pyproject.toml # Dependencies: mcp, pyyaml, httpx
├── README.md # This file
├── llm_chat_mcp/
│ ├── __init__.py
│ ├── __main__.py # CLI entry point + tool registration
│ ├── config.py # Config loading, model resolution
│ └── api.py # API client, error handling
└── tests/
└── test_output_strategies.py # Tests for append, inline_preview, auto_file测试
python tests/test_output_strategies.py测试会模拟 API 调用,并验证文件写入和响应组装逻辑。覆盖 output_file_path、append、inline_preview_chars 和 auto_file_threshold 的所有组合。
This server cannot be deployed
Maintenance
Related MCP Connectors
Provides capabilities that let LLM agents perform a range of infrastructure management tasks.
LLM chat, text tools, image generation, editing, batch image jobs, and asynchronous video generation
Messaging tools for AI agents: send messages, manage chats, groups and channels.
Manage portable AI agent playbooks, Agent Skills, MCP configurations, personas, and memory.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables interaction with locally running Ollama models through chat, generation, and model management operations. Supports listing, downloading, and deleting models while maintaining conversation history for interactive sessions.359 npmMIT
- AlicenseAqualityDmaintenanceEnables AI agents to connect to and chat with multiple LLM models (OpenAI, OpenRouter, custom endpoints) with conversation history management and model switching capabilities.314 npm2MIT
- AlicenseNot gradedqualityDmaintenanceProvides tools to interact with OpenAI API including chat completions, embeddings, content moderation, and file management through natural language.MIT
- AlicenseNot gradedqualityDmaintenanceEnables local task execution using the user's NVIDIA NIM API quota, with tools to process file contents through LLMs, send chat prompts, and list available models.189 npmMIT