Skip to main content
Glama

agentcast-mcp

npm tests mcp

一个 MCP 服务器,使 AI 助手能够强制执行结构化输出:从混乱的 LLM 文本中提取 JSON,根据形状规范进行门控,并在模型返回错误形状时生成重试反馈消息。

构建于 @mukundakatta/agentcast 之上。适用于 Claude Desktop、Cursor、Cline、Windsurf、Zed 以及任何其他 MCP 客户端。

公开的工具

extract_json

从混乱的 LLM 输出中提取 JSON 值。尝试整个文本,然后是带围栏的 ```json ``` 块,最后是最大的平衡 {...} / [...] 子字符串。返回解析后的值以及成功的策略。

{
  "text": "Sure, here you go:\n```json\n{\"answer\": 42}\n```\nLet me know!"
}

→

{
  "value": { "answer": 42 },
  "found": true,
  "source": "fenced_json"
}

source 是 whole、fenced_json、fenced_plain、balanced_substring 或 none 之一。

validate_response

根据 agentcast 形状规范验证解析后的 JSON 值。规范将字段名称映射到类型:string、number、boolean、array、object。后缀加 ? 表示可选。

{
  "value": { "name": "ada" },
  "shape": { "name": "string", "age": "number" }
}

→

{
  "valid": false,
  "error": "missing required field 'age'"
}

build_retry_prompt

给定尝试历史记录,生成当模型返回错误形状时 agentcast 附加到对话中的验证错误反馈消息。为希望手动驱动相同重试循环的非 Node MCP 客户端编纂了“验证错误作为反馈”模式。

{
  "attempts": [
    { "text": "{\"name\":\"ada\"}", "error": "missing required field 'age'" }
  ],
  "expected_shape": { "name": "string", "age": "number" }
}

→

{
  "feedback": "Your previous response did not match the required shape. Error: missing required field 'age'\n\nTry again. Respond with ONLY valid JSON that fixes the error above.\n\nExpected shape: {\"name\":\"string\",\"age\":\"number\"}"
}

Related MCP server: genpark-structured-extract-schema-validator-skill

安装

Claude Desktop

添加到 claude_desktop_config.json:

{
  "mcpServers": {
    "agentcast": {
      "command": "npx",
      "args": ["-y", "@mukundakatta/agentcast-mcp"]
    }
  }
}

Cursor / Cline / Windsurf / Zed

相同的形状,在您客户端对应的 mcp.json 中。大多数客户端通过 npx -y @mukundakatta/agentcast-mcp 自动发现。

本地安装

npm install -g @mukundakatta/agentcast-mcp
mcp-agentcast        # listens on stdio

为什么这很重要

当 LLM 应该返回结构化数据时,它有时会用散文、围栏或幻觉字段包裹 JSON。标准的 JSON.parse 会抛出错误。手动编写的正则表达式会错过嵌套结构。此 MCP 服务器为驱动代理的任何模型提供了真正的控制权,用于 (1) 从响应中提取 JSON,(2) 检查它是否符合预期的形状,以及 (3) 构建精确的重试提示,引导模型在下一轮中修复它。

许可证

MIT。

Available Tools

3 tools
build_retry_promptA

Given an attempt history, produce the retry feedback message agentcast would append to the conversation when the model returned the wrong shape. Codifies the "validation error as feedback" pattern for non-Node MCP clients.

Inputs: attempts (required), expected_shape.

extract_jsonA

Pull a JSON value out of messy LLM output. Tries the whole text, then a fenced json block, then the largest balanced {...}/[...] substring. Returns the parsed value plus which strategy succeeded.

Inputs: text (required).

validate_responseA

Validate a parsed JSON value against an agentcast shape spec. Spec maps field name to type: 'string', 'number', 'boolean', 'array', 'object'. Suffix with '?' for optional. Returns valid=true on success, or valid=false with a human-readable error string suitable for retry feedback.

Inputs: shape (required), value (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4/5.0

    Scored across 3 tools

    Disambiguation5/5

    Each tool has a clear, distinct purpose: build_retry_prompt handles feedback generation, extract_json extracts JSON from text, and validate_response checks JSON against a spec. There is no functional overlap.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern in snake_case (build_retry_prompt, extract_json, validate_response), making them predictable and easy to understand.

    Tool Count4/5

    With only 3 tools, the server is slightly underpopulated but still appropriately scoped for the narrow domain of agent response validation and retry feedback. It covers the core workflow without unnecessary bloat.

    Completeness4/5

    The tools cover the essential pipeline of extracting JSON, validating it against a spec, and generating retry feedback. A minor gap is the lack of explicit handling of attempt history beyond what build_retry_prompt expects, but that is assumed provided by the client.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Deterministic JSON validation and repair for AI agents. Validates, repairs, schema-checks, and diffs JSON so long-running agents don't corrupt their session state with malformed writes.
      MIT