Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add instructions/chaselen/knife4j-mcp/agents-mdgit clone --depth 1 https://github.com/chaselen/knife4j-mcpWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/instructions/chaselen/knife4j-mcp/agents-md)<a href="https://agentmods.dev/instructions/chaselen/knife4j-mcp/agents-md"><img src="https://agentmods.dev/badge/instructions/chaselen/knife4j-mcp/agents-md.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00912 | $0.00912 |
| Opus 5 | $0.00456 | $0.00456 |
| Sonnet 5 | $0.00182 | $0.00182 |
| Haiku 4.5 | $0.00091 | $0.00091 |
Grade A, and why
knife4j-mcp AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
What it actually says
AGENTS.md
项目目标
本仓库用于实现一个基于 Node.js + TypeScript 的 MCP server,用来读取 Knife4j / Swagger 多模块接口文档,并为 Codex 或其他支持 MCP 的 Agent 提供接口查询能力。
这个服务的核心用途是:
- 读取
/swagger-resources - 拉取每个模块对应的 Swagger/OpenAPI 文档
- 在内存中建立统一搜索索引
- 根据路径、关键词、tag、operation 信息查询接口
实现上优先保持轻量、清晰、可本地运行。
当前技术栈
- Node.js
- TypeScript
@modelcontextprotocol/sdkzod- 少量 Node 标准库能力
没有明确必要时,不要引入重型框架。
关键文件
src/index.ts:stdio MCP server 启动入口src/server.ts:MCP tools 注册src/swagger-registry.ts:spec 拉取、缓存、索引、查询src/swagger-parser.ts:Swagger 2 / OpenAPI 3 统一抽取与映射src/http.ts:认证请求与 URL 解析examples/mock-swagger-server.ts:本地多模块 Swagger mock 服务scripts/smoke-test.ts:stdio MCP 联调 smoke testREADME.md:使用说明与验证步骤
MCP Tools
当前已提供这些 tools:
list_specsfind_apiget_api_detailrefresh_specs
如果修改 tool 行为,请遵循:
- 输出保持结构化,优先返回适合 Agent 消费的 JSON
- 除非有明确目的,不要随意改掉现有核心字段
- 优先做兼容性增强,不轻易做破坏性 schema 变更
环境变量
当前支持的运行配置:
SWAGGER_RESOURCES_URL(必填)SWAGGER_BASE_URLSWAGGER_BASIC_AUTHSWAGGER_HEADERSSWAGGER_MODULE_ALLOWLISTCACHE_TTL_MSLOG_LEVEL
不要在源码中硬编码账号、密码、token 或其他敏感信息。
协作和编码方式
- 优先实现最小可运行版本,再逐步迭代。
- 优先复用现有的
registry + parser + server分层,不随意新增平行抽象。 - 保持 Swagger 2.0 支持稳定;OpenAPI 3 在可控范围内尽量兼容。
- 做好局部失败隔离:单个模块 spec 拉取失败,不应导致整个服务不可用。
- 能用 Node 内置能力或现有结构解决的问题,不要额外加依赖。
验证方式
完成较重要代码改动后,优先执行:
npm run build
做端到端验证时,使用:
MOCK_SWAGGER_BASIC_AUTH=demo:demo npm run mock:swagger
SWAGGER_RESOURCES_URL=http://127.0.0.1:3301/swagger-resources SWAGGER_BASIC_AUTH=demo:demo npm run test:smoke
如果改动影响索引逻辑、查询逻辑或 tool 输出,至少验证:
list_specsfind_apiget_api_detail
实现注意事项
swagger-resources返回的模块地址可能是相对路径,必须正确补全。- 先把 Swagger/OpenAPI 文档映射成统一内部模型,再做搜索和查询逻辑。
- 搜索结果应尽量简洁;详情结果应尽量完整,方便 Agent 联调。
- 日志保持简洁即可,本地 MCP 使用场景下输出到 stderr 是可以接受的。
变更边界
- 不要做与当前目标无关的大范围重构。
- 没有强理由时,不要重命名 MCP tools。
- 不要提交真实凭证、敏感配置或环境私有数据。
- 当启动方式、脚本、配置项或接入方式变化时,要同步更新
README.md。
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 5d ago First seen · 108 lines · 912 tokens per session scan A 55f5074282b4
knife4j-mcp AGENTS.md is an instructions file published in the GitHub repository chaselen/knife4j-mcp (0 stars, last pushed 1mo ago), licensed MIT. It adds 912 tokens to every session, about $0.0046 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other instructions, from other repositories
wjx-ai-kit CLAUDE.md
Claude Code instructions for wjxcom/wjx-ai-kit, covering claude.md, what this is, build & test commands, install all workspace dependencies and build (from monorepo root) — cli is the main product.
apifable AGENTS.md
AGENTS.md instructions for ycs77/apifable, covering agents.md, keep this file strict, constraints, commands and rules.
omnivox-mcp CLAUDE.md
Claude Code instructions for Beat-YT/omnivox-mcp, covering claude.md, project overview, commands, transport modes and architecture.
typescript AGENTS.md
AGENTS.md instructions for typeship-ax/typescript, covering typeship — agent context, ground rules, authentication, using the sdk and documentation.
specmatic-mcp-server AGENTS.md
Instructions for specmatic/specmatic-mcp-server, covering agents.md, project overview, current state, development setup and prerequisites.
planday-bridge AGENTS.md
AGENTS.md instructions for MVPR-Ext-Projects/planday-bridge, covering planday-bridge — context for ai coding agents, what this is, architecture, traps and write safety — do not weaken this.