mcp-server-llmling 是一个基于机器聊天协议(MCP)的服务器,提供了一个基于 YAML 的配置系统用于 LLM 应用程序。
LLMLing,作为后端,提供了一个基于 YAML 的配置系统用于 LLM 应用程序。它允许设置自定义的 MCP 服务器来提供在 YAML 文件中定义的内容。
YAML 配置创建了一个完整的环境,为 LLM 提供了:
PathResource)TextResource)CLIResource)SourceResource)CallableResource)ImageResource)在你的 settings.json 中添加 LLMLing 作为上下文服务器:
{
"context_servers": {
"llmling": {
"command": {
"env": {},
"label": "llmling",
"path": "uvx",
"args": [
"mcp-server-llmling",
"start",
"path/to/your/config.yml"
]
},
"settings": {}
}
}
}
在你的 claude_desktop_config.json 中配置 LLMLing:
{
"mcpServers": {
"llmling": {
"command": "uvx",
"args": [
"mcp-server-llmling",
"start",
"path/to/your/config.yml"
],
"env": {}
}
}
}
从命令行直接启动服务器:
# 最新版本
uvx mcp-server-llmling@latest
from llmling import RuntimeConfig
from mcp_server_llmling import LLMLingServer
async def main() -> None:
async with RuntimeConfig.open(config) as runtime:
server = LLMLingServer(runtime, enable_injection=True)
await server.start()
asyncio.run(main())
from llmling import RuntimeConfig
from mcp_server_llmling import LLMLingServer
async def main() -> None:
async with RuntimeConfig.open(config) as runtime:
server = LLMLingServer(
config,
transport="sse",
transport_options={
"host": "localhost",
"port": 3001,
"cors_origins": ["http://localhost:3000"]
}
)
await server.start()
asyncio.run(main())
resources:
python_code:
type: path
path: "./src/**/*.py"
watch:
enabled: true
patterns:
- "*.py"
- "!**/__pycache__/**"
api_docs:
type: text
content: |
API 文档
================
...
tools:
analyze_code:
import_path: "mymodule.tools.analyze_code"
description: "分析 Python 代码结构"
toolsets:
api:
type: openapi
spec: "https://api.example.com/openapi.json"
[!TIP] 对于 OpenAPI 模式,你可以安装 Redocly CLI 来捆绑和解析 OpenAPI 规范,然后再将其与 LLMLing 一起使用。这有助于确保你的模式引用被正确解析,并且规范格式正确。如果已安装 Redocly,它将自动使用。
服务器通过 YAML 文件进行配置,包含以下部分:
global_settings:
timeout: 30
max_retries: 3
log_level: "INFO"
requirements: []
pip_index_url: null
extra_paths: []
resources:
# 资源定义...
tools:
# 工具定义...
toolsets:
# 工具集定义...
prompts:
# 提示定义...
服务器实现了 MCP 协议,支持以下操作:
资源操作
工具操作
提示操作
通知