1C AI MCP
1C AI MCP - 用于1C:Напарник的MCP服务器
用于将IDE与1С:Напарник API集成的MCP服务器(Model Context Protocol)。基于FastMCP(Python)构建,打包为Docker。可与Cursor、Claude Code及任何MCP兼容客户端配合使用。
12个工具:代码分析(检查、审查、重构)和文档搜索(ITS、平台、配置)。
基于comol/1c-code-checker的想法,并采用了SteelMorgan/spring-mcp-1c-copilot中修正的API格式(422错误)算法。
前置要求
Docker(或Docker Desktop)
1С:Напарник令牌 - 在code.1c.ai获取(需要ITS订阅)
Related MCP server: 1C_MCP_SERVER_OWN
快速开始
方案A:使用Docker Hub现成镜像(推荐)
docker run -d --name 1c-ai-mcp -p 8007:8007 \
-e ONEC_AI_TOKEN="ваш-токен" \
desko77/1c-ai-mcp:latest或通过Docker Compose - 创建docker-compose.yml文件:
services:
1c-ai-mcp:
image: desko77/1c-ai-mcp:latest
container_name: 1c-ai-mcp
ports:
- "8007:8007"
environment:
ONEC_AI_TOKEN: "${ONEC_AI_TOKEN}"
restart: always# Создать .env с токеном (не попадает в git)
echo 'ONEC_AI_TOKEN=ваш-токен' > .env
# Запустить
docker compose up -d方案B:从源码构建
git clone https://github.com/Desko77/1c-ai-mcp.git
cd 1c-ai-mcp
# Создать .env с токеном
echo 'ONEC_AI_TOKEN=ваш-токен' > .env
# Собрать и запустить
docker compose up -d --build功能验证
# Должен вернуть HTTP 200
curl http://localhost:8007/mcp连接IDE
Cursor
在~/.cursor/mcp.json中添加:
{
"mcpServers": {
"1c-naparnik": {
"url": "http://localhost:8007/mcp"
}
}
}Claude Code
在~/.claude/settings.json中添加:
{
"mcpServers": {
"1c-naparnik": {
"url": "http://localhost:8007/mcp"
}
}
}其他MCP客户端
端点:http://localhost:8007/mcp
传输方式:Streamable HTTP(默认)或SSE(USESSE=true)。
工具
代码分析
check_1c_code
1C代码检查:语法、逻辑、性能。在direct模式下,语法通过upstream syntax-checker检查。
参数 | 类型 | 描述 |
| string | 要检查的1C代码 |
| string |
|
ask_1c_ai
向1С:Напарник提出任意问题。在多次调用之间保存对话上下文。
参数 | 类型 | 描述 |
| string | 问题 |
| bool | 新会话(默认 |
review_1c_code
代码审查:风格、ITS标准、命名、结构、可读性。不检查语法。
参数 | 类型 | 描述 |
| string | 要审查的1C代码 |
rewrite_1c_code
AI提供其改进后的代码版本,并附修改说明。
参数 | 类型 | 描述 |
| string | 要重写的1C代码 |
| string | 方向: |
modify_1c_code
根据明确指令修改代码。如果未指定代码 - 则生成新代码。
参数 | 类型 | 描述 |
| string | 所需修改的描述 |
| string | 源代码(可选) |
explain_1c_syntax
解释1C语法的具体元素。
参数 | 类型 | 描述 |
| string | 语法元素 |
| string | 使用上下文(可选) |
文档与帮助
its_help
搜索ITS知识库(标准、方法、文章)。返回用于fetch_its的文档ID。
参数 | 类型 | 描述 |
| string | 搜索查询 |
fetch_its
按标识符读取ITS文档。在its_help之后使用。
参数 | 类型 | 描述 |
| string | 文档ID( |
search_1c_documentation
搜索特定版本的1С:Предприятие平台文档。
参数 | 类型 | 描述 |
| string | 搜索查询 |
| string | 版本(默认 |
onec_help
搜索平台文档(最新版本)。与search_1c_documentation相同,但不指定版本。
参数 | 类型 | 描述 |
| string | 搜索查询 |
diff_1c_documentation_versions
比较两个版本之间的平台文档。
参数 | 类型 | 描述 |
| string | 较早版本(例如 |
| string | 较晚版本(例如 |
| string | 主题领域(可选) |
config_help
搜索应用配置文档(ERP、会计、ZUP、UT等)。
参数 | 类型 | 描述 |
| string | 搜索查询 |
| string | 配置名称(可选,取自 |
配置
所有参数通过环境变量传递。
变量 | 必填 | 默认值 | 描述 |
| 是* | - | 1С:Напарник API令牌 |
| 否 | - | 令牌文件路径(Docker Secrets) |
| 否 |
| API基础URL |
| 否 |
| 对话技能( |
| 否 |
| Authorization格式: |
| 否 |
| HTTP请求超时(秒) |
| 否 | - | 用于config_help的配置(例如 |
| 否 |
| 模式: |
| 否 |
| 输入数据最大长度(字符) |
| 否 |
| MCP服务器端口 |
| 否 |
| 传输方式: |
| 否 |
| 并发会话限制 |
| 否 |
| 会话TTL(秒) |
| 否 |
| 日志级别( |
* 必须设置ONEC_AI_TOKEN或ONEC_AI_TOKEN_FILE。
Docker Secrets
对于生产环境,令牌可以通过文件传递:
services:
1c-ai-mcp:
image: desko77/1c-ai-mcp:latest
environment:
ONEC_AI_TOKEN_FILE: /run/secrets/onec_token
secrets:
- onec_token
secrets:
onec_token:
file: ./onec_token.txtDirect模式
当MCP_TOOL_CALL_MODE=direct时,文档工具和check_1c_code(syntax)直接按名称调用1С:Напарник的upstream工具,而不是使用文本提示词。这样可以获得更精确的结果。
Upstream工具:
mcp__knowledge-hub__Search_ITS- 用于its_helpmcp__knowledge-hub__Fetch_ITS- 用于fetch_itsmcp__knowledge-hub__Search_Documentation- 用于search_1c_documentation、onec_helpmcp__knowledge-hub__Diff_Documentation_Versions- 用于diff_1c_documentation_versionsmcp__syntax-checker__validate- 用于check_1c_code(syntax)
direct调用失败时自动回退到提示词模式。默认为standard以保持向后兼容。
架构
MCP-клиент (Cursor / Claude Code)
-> FastMCP HTTP endpoint (:8007/mcp)
-> mcp_server.py (обработчики инструментов)
-> OneCApiClient (HTTP-клиент)
-> code.1c.ai API (SSE-стриминг)
-> парсинг ответа -> возврат клиенту两种工作模式
Standard模式(默认):工具生成文本提示词并发送到API。文档工具使用工具链 - 模型自行决定调用哪个服务器端工具。
Direct模式(
MCP_TOOL_CALL_MODE=direct):工具显式按名称请求特定的upstream工具,匹配响应并确认调用。失败时自动回退到standard模式。
SSE解析器
支持三种API响应格式:
格式 | 结构 | 类型 |
Legacy |
| 增量式 |
OpenAI-like |
| 增量式 |
Completed |
| 最终式 |
此外:
自动从响应中移除
<thinking>/thinking块Unicode规范化并清理控制字符
收到
tool_calls时的回退 - 使用skill_name="raw"重新请求按
ONEC_AI_INPUT_MAX_LENGTH截断输入数据
开发
无需Docker的本地运行
pip install -r requirements.txt
export ONEC_AI_TOKEN="ваш-токен"
python main.py项目结构
main.py # Точка входа
src/
mcp_server.py # MCP-инструменты (@mcp.tool)
onec_api_client.py # HTTP-клиент к API 1С:Напарник
Dockerfile # Dockerfile
docker-compose.yml # Compose для сборки из исходников
tests/ # Тестовые скрипты
.github/workflows/
docker-publish.yml # CI: сборка и публикация в Docker Hub致谢
comol/1c-code-checker - 原始想法(仓库已关闭)
SteelMorgan/spring-mcp-1c-copilot - 正确的API算法
FastMCP - MCP服务器框架
许可证
MIT - 参见LICENSE
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityFmaintenanceProvides a RAG-based search system for 1C:Enterprise platform documentation using hybrid BM25 and semantic search across multiple versions. It enables developers to retrieve API signatures, methods, and usage examples directly within IDEs or through a REST API.22MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with 1C:Enterprise databases through natural language, providing metadata retrieval, configuration analysis, and code generation.9
- AlicenseNot gradedqualityAmaintenanceEnables searching through 1C:Enterprise configuration source code (XML+BSL) with full-text indexing, providing tools to find code, metadata objects, procedures, and modules.MIT
- AlicenseNot gradedqualityAmaintenanceEnables AI agents to lint, search documentation, and perform metadata scaffolding for 1C:Element projects.1MIT
Related MCP Connectors
Get up-to-date, version-specific documentation and code examples from official sources directly in…
Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.
Provide AI-powered real-time analysis and intelligence on NPM packages, including security, depend…
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/serezhenkov-lab/1c-ai-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server