kb-mcp-server: Instructions file for Claude Code

CLAUDE.md

kb-mcp-server CLAUDE.md is an instructions file for Claude Code from code-runner-xx/kb-mcp-server. It costs 1,706 tokens per session, scanned A, original, MIT.

Development instructions for kb-mcp-server, a Python service that exposes a knowledge-base search system through MCP. A knowledge base is a collection of stored information that can be searched by questions.

In plain words
What is it for?
Building and testing a Chinese-language knowledge-base search server that reads from the existing online database service. The instructions cover setup, tenant isolation, secrets, and empty-search responses.
Why use it?
It defines the project’s security, language, logging, read-only, and step-by-step approval rules, reducing the risk of leaking data or breaking the MCP communication channel.

Instructions file for Claude Code

Written for Claude Code: the file is CLAUDE.md. Also seen: mentions CLAUDE.md; mentions Claude Code.

This is code-runner-xx/kb-mcp-server's own configuration. It tells Claude Code how to work on kb-mcp-server itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything kb-mcp-server configures →

Reuse

Borrowing it

Nothing to install: this file belongs to code-runner-xx/kb-mcp-server. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/code-runner-xx/kb-mcp-server/main/CLAUDE.md
Clone the repo
git clone --depth 1 https://github.com/code-runner-xx/kb-mcp-server

Made for: Claude Code.

Wrote 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.

agentmods badge for kb-mcp-server CLAUDE.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/code-runner-xx/kb-mcp-server/claude-md/github.svg)](https://agentmods.dev/instructions/code-runner-xx/kb-mcp-server/claude-md)
Your own site
<a href="https://agentmods.dev/instructions/code-runner-xx/kb-mcp-server/claude-md"><img src="https://agentmods.dev/badge/instructions/code-runner-xx/kb-mcp-server/claude-md/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for kb-mcp-server CLAUDE.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/code-runner-xx/kb-mcp-server/claude-md"><img src="https://agentmods.dev/badge/instructions/code-runner-xx/kb-mcp-server/claude-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 1,706 This file is loaded in full into every session.
When invoked 1,706 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5.1 $0.01706 $0.01706
Opus 5.5 $0.00682 $0.00682
Sonnet 5.5 $0.00341 $0.00341
Haiku 4.5 $0.00171 $0.00171

Measured 2mo ago against content hash a559c0695aec, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

kb-mcp-server CLAUDE.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 2mo 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.

CLAUDE.md · 111 lines

How it starts

The opening of the file, as written. The whole thing — 111 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CLAUDE.md — kb-mcp-server 开发手册(规则书)

独立于 ai-customer-service-saas(下称 aisc)的新项目:用官方 MCP Python SDK 把 aisc 的知识库检索能力封装成标准 MCP Server。

本文件是 Claude Code 的权威执行指南。每完成一个 Step 必须停下,输出"✅ 验收方案"让用户手动测试,用户回复"通过"后才能进入下一步。禁止跳步、禁止一次性写完多个 Step。

配套文档:PLAN.md — M1-M7 分步计划与验收标准。


0. 项目铁律(必读)

  1. stdio 模式下绝对禁止 print() 到 stdout。stdout 就是 JSON-RPC 通道,一行 print 直接把协议打挂。调试日志一律用 logging(默认走 stderr)。这是本项目第一铁律。
  2. 语言:注释、commit message、工具 description 与返回文案使用简体中文;代码标识符使用英文。
  3. Secrets:真实 key 永不进代码与 git,仓库只提交 .env.example 占位;日志不打印 key 和完整 chunk 内容。
  4. 租户隔离:所有 SQL/RPC 固定 user_id = KB_TENANT_ID(服务端从环境变量读取写死),绝不把 tenant_id 暴露为工具参数。Service Role Key 会绕过 RLS,这正是必须显式过滤的原因。
  5. 全部工具只读幂等:不暴露任何写入/删除操作(最小权限原则)。
  6. 中文返回:json.dumps(..., ensure_ascii=False),否则模型看到 \uXXXX。
  7. 零命中:返回明确文案「知识库中没有与该问题相关的内容」,不返回空数组(模型对空数组解读不稳定)。
  8. 不要自作主张:本手册与 PLAN.md 未写清楚的细节,先在回答开头列出"❓ 待确认"问用户。
  9. 不擅自升级依赖:以下文版本锁定为准,遇到不一致的 API 写法以锁定版本为准。
  10. 对 aisc 零改动:本项目只读复用 aisc 的线上 Supabase RPC 与 SiliconFlow key,严禁修改 aisc 仓库的任何文件、表结构或 RPC 函数。

1. 版本与技术选型(锁定)

项 选择 说明
语言 Python 3.11
SDK 官方 mcp 包(内置 FastMCP),pip install "mcp[cli]" 社区另有独立 FastMCP 2.x/3.x 包,不用,以官方 SDK 为准
传输 stdio(本地) Streamable HTTP 仅 M7 加分项
Embedding SiliconFlow BAAI/bge-m3 1024 维,与 aisc 同源,严禁换模型(RPC 不报错但检索静默错配)
数据访问 supabase-py 调 RPC match_document_chunks 直连 aisc 线上库,零迁移
依赖管理 uv Claude Desktop 配置里直接写 uv run
调试工具 npx @modelcontextprotocol/inspector 先 Inspector 后 Desktop,Desktop 报错信息极少

2. 环境变量(.env.example)

SUPABASE_URL=
SUPABASE_SERVICE_ROLE_KEY=
SILICONFLOW_API_KEY=
KB_TENANT_ID=

KB_TENANT_ID = aisc 中你的 user_id,写死实现租户隔离。

注意:Claude Desktop 配置中的 env 字段需显式列出全部四个变量,Server 进程不继承终端环境变量。


3. 目录结构

kb-mcp-server/
├── server.py          # FastMCP 入口:工具/资源/提示词定义
├── kb.py              # embedding 调用 + Supabase 检索封装(纯函数,可独立测试)
├── .env.example       # 环境变量占位(真实 .env 不进 git)
├── pyproject.toml
├── README.md
├── CLAUDE.md          # 本文件
├── PLAN.md            # 分步计划
└── tests/manual_test.md  # 手测用例清单

Read the full file on GitHub · 111 lines

Changes

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.

  1. 2mo ago First seen · 111 lines · 1,706 tokens per session scan A a559c0695aec

Subscribe to this mod's changes

kb-mcp-server CLAUDE.md is an instructions file published in the GitHub repository code-runner-xx/kb-mcp-server (0 stars, last pushed 4mo ago), licensed MIT. It adds 1,706 tokens to every session, about $0.0068 per session on Opus 5.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.

Related

kb-mcp-server CLAUDE.md compared with instructions from other repositories

kb-mcp-server CLAUDE.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
kb-mcp-server CLAUDE.mdcode-runner-xx/kb-mcp-serverInstructions file04mo agoMITA1,706Claude Code
vscode buildNext.instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA9,719GitHub Copilot
next.js AGENTS.mdvercel/next.jsInstructions file143kyesterdayMITA7,461Codex, OpenCode
langchain AGENTS.mdlangchain-ai/langchainInstructions file149kyesterdayMITA4,680Codex, OpenCode
vscode oss-third-party-notices.instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA5,516GitHub Copilot
vscode copilot-instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA3,093GitHub Copilot
deepseek-harness AGENTS.mddeepseek-ai/deepseek-harnessInstructions file274k2d agoMITA4,313Codex, OpenCode