Skip to main content
Glama

llm-chat-mcp

用于与 Continue.dev 的 config.yaml 中配置的 LLM 模型进行交互的 MCP 服务器。

功能

暴露 4 个工具,让代理可以检查你配置的模型并向其发送聊天请求:

  • llm_chat_list_models — 列出配置中的所有模型及其名称和 id

  • llm_chat_get_model_params — 检查任意模型的参数(temperature、topP 等)

  • llm_chat_get_model_prompt — 读取为模型配置的系统提示词

  • llm_chat_send_request — 与模型聊天,可选覆盖参数或从文件加载提示词

安装

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 PATH

config.yaml 的路径

~/.continue/config.yaml

--default-model NAME

send_request 的默认模型

(无)

--timeout SECONDS

请求超时时间(秒)

19

--relative_paths_base PATH

用于解析相对输出文件路径的基础目录

(进程当前工作目录)

--auto-output-dir PATH

当响应超过 auto_file_threshold 且未设置 output_file_path 时,自动生成输出文件的目录

(操作系统临时目录)

配置

  • 每次请求都会重新读取配置 — 无需重启

  • 认证使用 config.yaml 中每个模型条目的 apiKey

  • 如果未指定模型(既未在 CLI 中指定,也未在工具调用中指定),会返回错误并提示如何设置

llm_chat_send_request 参数

主要工具。向 LLM 发送聊天补全请求并返回响应。

输入参数

参数

类型

默认值

描述

model_selector

str

(CLI 默认值)

config.yaml 中的模型名称或 id

prompt_text

str

(无)

要发送的提示词文本

prompt_files

list

(无)

文件规格列表(字符串路径或 {path, start_line, end_line} 字典)

include_line_numbers

bool

true

为每个文件行添加 N: 前缀

system_prompt

str

(来自配置)

覆盖系统消息;"" 表示完全禁用

temperaturetopPtopKminP

float

(来自配置)

采样参数

maxTokenspresencePenaltyfrequencyPenalty

int/float

(来自配置)

生成参数

extraParams

dict

(无)

合并到 API 请求中的额外 body 属性

details

bool

false

在响应中包含推理/思考内容

timeout

float

(CLI 默认值)

单次请求的超时覆盖

output_file_path

str

(无)

将完整响应写入此文件(相对路径基于 --relative_paths_base 解析)

append

bool

false

追加到 output_file_path 而不是覆盖;返回 appended_line_start/appended_line_end

inline_preview_chars

int

500

内联返回的内容最大字符数;仅当写入文件时预览才生效

auto_file_threshold

int

8000

response_chars 超过此值且未设置 output_file_path 时自动将响应写入文件;0 表示禁用

响应结构

始终以 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
  }
}

输出策略

该工具根据参数和响应大小选择以下三种策略之一:

  1. 显式文件(设置了 output_file_path):完整响应写入文件。如果 append=true,响应会被追加,并返回 appended_line_start/appended_line_end(从 1 开始,包含两端),以便调用方可以通过 extract_lines 只读取追加的部分。

  2. 自动文件(未设置 output_file_pathauto_file_threshold > 0response_chars > threshold):完整响应写入 --auto-output-dir(或操作系统临时目录)中自动生成的文件。文件名格式:llm_output_<YYYYMMDD_HHMMSS>_<6-char-uuid>.json

  3. 仅内联(未写入文件):完整内容在 content 字段中返回。

内联预览

当写入文件时(显式或自动),content 字段包含响应的预览:

  • 如果 inline_preview_chars > 0len(content) > inline_preview_chars:截断的预览,带有后缀 [truncated, full response in <file_path>]

  • 如果 inline_preview_chars > 0len(content) <= inline_preview_chars:完整内容(适合预览)。

  • 如果 inline_preview_chars == 0content 为空(文件包含完整响应)。

当未写入文件时,无论 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_pathappendinline_preview_charsauto_file_threshold 的所有组合。

-
license - not tested
Not graded
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

  • LLM chat, text summarization and AI image generation

  • Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.

  • Gateway between LLM agents and world data through eight tools and a bundled endpoint catalog.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nikolay-martynov/mcp-llm-chat'

If you have feedback or need assistance with the MCP directory API, please join our Discord server