
Guidance Lark Mcp
io.github.guidance-ai由 GitHub 账号 guidance-ai 发布v0.1.2更新于 Oct 24, 2026
Validate and test llguidance grammars with batch testing and documentation
概览
本地 MCP 服务器,用于校验和批量测试 llguidance 的 Lark 语法,并提供语法文档与可选的语法约束生成。
- 可以做什么
- 用 llguidance 内置校验器检查 Lark 语法是否完整、一致
- 依据 JSON 测试文件对语法运行批量校验测试,返回通过/失败统计与失败详情
- 从官方仓库获取 llguidance 语法语法文档
- 可选:使用受语法约束的 OpenAI 兼容模型生成文本,使输出符合语法
- 适用场景
- 适合与 AI 助手一起迭代构建或调试 llguidance Lark 语法,例如把语言规范中的规则转写为 Lark 并用样例输入反复测试直到全部通过。
- 运行要求
- 以 Python 包形式通过 stdio 在本地运行,可用 uvx 或 pip 安装。语法校验、批量测试和文档功能无需凭据。可选的生成工具需要 ENABLE_GENERATION=true 以及 OPENAI_API_KEY,或 Azure OpenAI 的 AZURE_OPENAI_ENDPOINT、AZURE_OPENAI_API_KEY 等设置,或配合 azure 扩展使用 az login。获取文档和调用模型后端需要网络访问。
安装
在 SourceWeft 中
- 打开 控制台中的 Guidance Lark Mcp,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
MCP Grammar Tools
MCP server for validating and testing llguidance grammars (Lark format). Provides grammar validation, batch test execution, and syntax documentation — ideal for iteratively building grammars with AI coding assistants.
Installation
With uvx (recommended)
With pip
From source
MCP Client Configuration
GitHub Copilot CLI
You can add the server using the interactive /mcp add command or by editing the config file directly. See the Copilot CLI MCP documentation for full details.
Option 1: Interactive setup
In the Copilot CLI, run /mcp add, select Local/STDIO, and enter uvx guidance-lark-mcp as the command.
Option 2: Edit config file
Add the following to ~/.copilot/mcp-config.json:
This gives you grammar validation and batch testing out of the box. To also enable LLM-powered generation (generate_with_grammar), add ENABLE_GENERATION and your credentials to env:
For Azure OpenAI (with Entra ID via az login), use guidance-lark-mcp[azure] and set the endpoint instead:
See Backend Configuration for all supported backends.
After saving, use /mcp show to verify the server is connected.
VS Code
Claude Desktop
Usage
Available Tools
-
validate_grammar— Validate grammar completeness and consistency using llguidance's built-in validator. -
run_batch_validation_tests— Run batch validation tests from a JSON file against a grammar. Returns pass/fail statistics and detailed failure info.Test file format:
-
get_llguidance_documentation— Fetch the llguidance grammar syntax documentation from the official repo. -
generate_with_grammar(optional, requiresENABLE_GENERATION=true) — Generate text using an OpenAI model constrained by a grammar. Uses the Responses API with custom tool grammar format, so output is guaranteed to conform to the grammar. RequiresOPENAI_API_KEYenvironment variable. See Backend Configuration for Azure and other endpoints.
Backend Configuration
The generate_with_grammar tool uses the OpenAI Python SDK, which natively supports multiple backends via environment variables:
The server auto-detects which backend to use:
- If
AZURE_OPENAI_ENDPOINTis set → usesAzureOpenAIclient (with Entra ID or API key) - Otherwise → uses
OpenAIclient (readsOPENAI_API_KEYandOPENAI_BASE_URLautomatically)
The server logs which backend it detects on startup.
Example: Azure OpenAI (API key)
Example: Azure OpenAI (Entra ID / keyless)
Requires az login and the azure extra: pip install guidance-lark-mcp[azure]
Example Workflow
Build a grammar iteratively with an AI assistant:
- Start with the spec — paste EBNF rules from a language specification
- Write a basic grammar — translate a few rules to Lark format
- Validate — use
validate_grammarto check for missing rules - Write tests — create a JSON test file with sample inputs
- Batch test — use
run_batch_validation_teststo find failures - Fix & repeat — refine the grammar until all tests pass
Example Grammars
The examples/ directory includes sample grammars built using these tools, with Lark grammar files, test suites, and documentation:
- GraphQL — executable subset of the GraphQL spec (queries, mutations, fragments, variables)
Troubleshooting
Server fails to connect in Copilot CLI / VS Code?
MCP clients like Copilot CLI only show "Connection closed" when a server crashes on startup. To see the actual error, run the server directly in your terminal:
Or with generation enabled:
Common issues:
- Missing credentials —
ENABLE_GENERATION=truewithout a validOPENAI_API_KEYorAZURE_OPENAI_ENDPOINT. The server will still start and serve validation tools;generate_with_grammarwill return a descriptive error. - Azure Entra ID — make sure you've run
az loginand are usingguidance-lark-mcp[azure](not the base package). - Slow first start —
uvxneeds to resolve and install dependencies on first run, which may exceed the MCP client's connection timeout. Runuvx guidance-lark-mcponce manually to warm the cache. - Updating to a new version —
uvxcaches packages, so after a new release you may need to clear the cache and restart your MCP client:
Development
来源:README.md,提交 65f1350
工具
0版本历史
1- v0.1.2最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分