sphinx-needs-mcp
Provides read-only tools for querying, searching, and tracing requirements from sphinx-needs-generated needs.json in Sphinx projects, including status reports and configurable rule checks.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@sphinx-needs-mcp trace SWR_001 to see what it refines and what verifies it"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
sphinx-needs-mcp
sphinx-needs が出力する needs.json を読み、要件・設計・検証ケースなどの need を、
AI エージェント(Claude Code など)から取得・検索・トレースできるようにする MCP サーバーです。
sphinx-needs の開発元(useblocks)とは関係のない、非公式のツールです。
何ができるか
ツールはすべて読み取り専用で、ファイルを書き換えません。
ツール | できること |
| プロジェクトにどんな need の型・リンク・フィールドがあるかを返します。最初にこれを呼びます |
| need 1 件の詳細(本文、フィールド、出ているリンクと向かってくるリンク、原稿の場所)を返します |
| 型・ステータス・フィールドの値・文字で絞り込んだ一覧を返します |
| リンクをたどって、上流(リンクの先)と下流(リンクの元)の need を返します |
| 型ごと・ステータスごとの件数と、リンクの張られ具合を返します。設定ファイルの |
| 設定ファイルに書いた網羅の規則を調べ、守れていない need と理由を返します(網羅の規則) |
need の型やリンクの名前はコードに決め打ちしていません。needs.json に入っているスキーマ
(needs_schema)から読み取るので、どのプロジェクトでもそのまま使えます。
ubproject.toml を渡すと、取り得る値の一覧(列挙値)やリンクの向きの呼び名も補います。
Related MCP server: @nlspec/server
使う前に:needs.json を作る
sphinx-needs のドキュメントをビルドすると needs.json ができます。次のどちらかで作れます。
conf.py(またはubproject.toml)でneeds_build_json = Trueを設定して、ふつうにビルドするneeds ビルダーを使う:
sphinx-build -b needs docs _build/needs
原稿を直したら、ビルドし直してから問い合わせてください。
--docs-dir を指定しておくと、原稿が needs.json より新しいときに、結果へ警告(warning)が付きます。
動作を確かめている sphinx-needs の版は 8.0 と 9.3 です。
Claude Code に登録する
リポジトリのルートに .mcp.json を置きます。uvx が、このリポジトリから直接インストールして起動します。
{
"mcpServers": {
"needs": {
"type": "stdio",
"command": "uvx",
"args": [
"--from", "git+https://github.com/harukikiya/sphinx-needs-mcp",
"sphinx-needs-mcp",
"--needs-json", "_build/html/needs.json",
"--ubproject", "docs/ubproject.toml"
]
}
}
}コマンドで登録することもできます。
claude mcp add needs -- uvx --from git+https://github.com/harukikiya/sphinx-needs-mcp \
sphinx-needs-mcp --needs-json _build/html/needs.json --ubproject docs/ubproject.toml版を固定したいときは、URL の後ろに @<タグかコミット> を付けてください。
引数
引数 | 意味 | 既定 |
| 読み込む |
|
|
| なし(なくても動きます) |
| 原稿のフォルダ。鮮度の確認と、原稿の場所の表示に使います |
|
| 網羅の規則などを書いた設定ファイル | 起動したフォルダの |
パスは、サーバーを起動したフォルダ(ふつうはリポジトリのルート)からの相対パスで書けます。
設定ファイルをリポジトリのルートに sphinx-needs-mcp.toml という名前で置けば、--config は要りません。
返す内容の例
get_need で SWR_001 を引いたときの結果です(テスト用のサンプルプロジェクトより)。
{
"id": "SWR_001",
"type": "swreq",
"title": "温度センサを読む",
"status": "approved",
"type_title": "ソフトウェア要件",
"tags": ["sensor"],
"content": "センサドライバは、温度センサから温度の生値を読み出すこと。",
"fields": {"layer": "driver"},
"links": {
"outgoing": {"refines": ["SYS_001"]},
"incoming": {"verifies": ["SWV_001", "SWV_002"]}
},
"source": "docs/software.md:3"
}links.outgoingは、この need から出ているリンクです(SWR_001 は SYS_001 を refines している)links.incomingは、この need に向かってくるリンクです(SWV_001 と SWV_002 が SWR_001 を verifies している)値が空のフィールドは省きます
網羅の規則(check_rules)
設定ファイル(sphinx-needs-mcp.toml)に、「この need は、このようにつながっていること」という規則を書けます。
check_rules は規則を 1 つずつ調べ、守れていない need と、その理由を返します。
[[rules]]
id = "swreq-is-verified"
description = "廃止していないソフトウェア要件は、検証ケースから参照されていること"
select = { type = "swreq", exclude_status = "obsolete" }
require = { incoming = "verifies", linked_type = "swverif" }
[[rules]]
id = "approved-has-no-structural-tbd"
description = "承認済みの need に、構造的 TBD(tbd_items)を残さないこと"
select = { status = "approved" }
require = { field = "tbd_items", empty = true }
[watch]
# 値が入っていたら、status_report の watched に一覧で出すフィールドです
fields = ["tbd_items", "open_params"]
# 型ごとに、フィールドの値の内訳(件数)を status_report の breakdowns に出します
[[watch.breakdowns]]
type = "swverif"
field = "environment"規則 1 つは、select(どの need に当てはめるか)と require(何を満たすべきか)の組です。
select:規則を当てはめる need
書いた条件はすべて「かつ」で組み合わせます。何も書かなければ全件が対象です。 値は文字列 1 つでも、文字列のリスト(どれか 1 つに当てはまればよい)でも書けます。
キー | 意味 | 例 |
| need の型 |
|
| ステータス |
|
| 外すステータス |
|
| フィールドの値( |
|
require:満たすべき条件
次のうち、どれか 1 つだけを書きます。
書き方 | 意味 |
| そのリンクで、ほかの need から参照されていること |
| そのリンクで、ほかの need を参照していること |
| そのフィールドに値が入っていること |
| そのフィールドが空であること |
incoming と outgoing には、次を足せます。
min = 2:最低限必要な本数(既定は 1)linked_type = "swverif":相手の need の型を限る(違う型からのリンクは数えません)
リンク先が存在しないリンク(dead link)は、つながっているとは数えません。
結果の例
{
"id": "swreq-is-verified",
"description": "廃止していないソフトウェア要件は、検証ケースから参照されていること",
"checked": 3,
"passed": false,
"violation_count": 1,
"violations": [
{
"id": "SWR_002",
"type": "swreq",
"title": "測定の周期を守る",
"status": "approved",
"reason": "swverif からの verifies で参照されていません(1 件以上必要です)"
}
]
}対象の need が 0 件だった規則には note が付きます。合格と言うより、select の書き間違いが疑われるためです。
ビルドの needs_warnings との関係
合否を決めるのは、これまでどおりビルドの needs_warnings です。check_rules は、
「どの need が、なぜ守れていないか」を調べたり、承認より前(draft のうち)に手当てが必要なものを
見つけたりするために使います。
needs_warnings は Python の式で書くので、MCP サーバーの中でそのまま実行(eval)するのは安全ではありません。
そのため、規則はこの設定ファイルに、実行しなくても意味が分かる形で書くようにしています。
rp2040-temp-monitor の status_report にあった集計(検証ケースのない SWR、TBD の一覧、検証環境ごとの件数)を
この形で書き直した例が、tests/fixtures/sample_project/sphinx-needs-mcp.toml にあります。
設計の方針
読み取り専用です。 合否の判定は、これまでどおり Sphinx のビルド(
needs_warningsと-W)に 任せます。この MCP は、AI が調べるための道具にとどめます呼ばれるたびに
needs.jsonと設定ファイルを読み直します。 ビルドし直した結果や、直した規則が、すぐに反映されます名前を間違えたら、候補を添えてエラーにします。 「0 件」とだけ返すと、間違いに気づきにくいためです
開発
uv を使います。
uv sync --group dev # 開発用の環境を作る
uv run pytest # テスト
uv run ruff check # lintテスト用の needs.json(tests/fixtures/needs-sphinx-needs-*.json)は、手で書かずに、
小さなサンプルプロジェクト(tests/fixtures/sample_project/)を本物の sphinx-needs でビルドして作ります。
作り直し方は scripts/make_fixtures.py の先頭に書いてあります。
ライセンス
BSD-3-Clause です。詳しくは LICENSE を見てください。
Available Tools
6 toolscheck_rulesARead-onlyIdempotent
設定ファイル(sphinx-needs-mcp.toml)の網羅の規則を調べ、守れていない need と理由を返します。
例:「承認済みのソフトウェア要件は、検証ケースから参照されていること」を守れていない要件。 合否を決めるのはビルドです。これは、どこを直せばよいかを細かく調べるためのものです。 規則の一覧は describe_project の rules で分かります。
Inputs: limit, rule_id. Returns: object
describe_projectARead-onlyIdempotent
プロジェクトにどんな need の型・リンク・フィールドがあるかを返します。
型やリンクの名前はプロジェクトごとに違います。 search_needs や trace を使う前に、まずこれで名前を確かめてください。 設定ファイルに網羅の規則があれば、その一覧(rules)も返します。
Inputs: no named parameters. Returns: object
get_needARead-onlyIdempotent
need 1 件の詳細を返します。
本文、プロジェクトのフィールド、出ているリンク(outgoing)と 向かってくるリンク(incoming)、原稿の場所(source)を含みます。 ID が分からないときは search_needs を使ってください。
Inputs: need_id (required). Returns: object
search_needsARead-onlyIdempotent
条件に合う need の一覧(ID・型・タイトル・ステータス)を返します。
条件はすべて「かつ」で組み合わせます。本文は返さないので、 気になった ID は get_need で詳しく見てください。
Inputs: text, limit, where, status, +1 more. Returns: object
status_reportARead-onlyIdempotent
プロジェクト全体の状況(件数とリンクの張られ具合)を返します。
型ごと・ステータスごとの件数、型ごと・リンクごとの「リンクを出している数・ 受けている数」、リンク先が存在しない need を含みます。 設定ファイルの [watch] に書いたもの(TBD などの注目するフィールドの一覧と、 値の内訳)があれば、それも足します。
Inputs: no named parameters. Returns: object
traceARead-onlyIdempotent
リンクをたどって、上流・下流の need を列挙します。
変更の影響範囲(このシステム要件を変えたら、どの要件と検証ケースに波及するか)は direction="down"、要件の出どころを確かめるときは "up" を使います。
Inputs: need_id (required), direction, max_depth, link_types. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool targets a distinct operation: schema discovery (describe_project), single-record detail (get_need), filtered listing (search_needs), link traversal (trace), aggregate stats (status_report), and rule validation (check_rules). The only mild overlap is between status_report and check_rules, both of which surface project-health issues (broken links vs. rule violations), but their descriptions draw a clear line between counts and rule compliance.
Four of six tools follow a clean verb_noun pattern (describe_project, get_need, search_needs, check_rules). The bare verb 'trace' and the noun-first 'status_report' are minor deviations but remain readable and unambiguous in context.
Six tools is well-scoped for a read-oriented requirements-inspection server. Each tool covers a distinct facet (schema, search, detail, tracing, stats, rules) with no redundancy or filler.
The read/analysis surface is comprehensive: schema discovery, search, detail, link tracing, project status, and rule checking form a coherent workflow with no dead ends for inspection. The main gap is the absence of any write/mutation tools (create/update/delete needs), though the server appears intentionally read-only, so this is a minor limitation rather than a failure.
Maintenance
Related MCP Connectors
Read and draft requirements, controlled documents and trace links in Traceable Docs.
Requirements authority for AI coding agents: binding requirements and acceptance criteria.
Turn datasheets into source-backed JSON contracts, pinout matrices, and KiCad CAD for AI agents.
Agent verification tools: CSV quality, citation checks, AI-readiness audits, requirement extraction
Related MCP Servers
- -licenseNot gradedqualityNot gradedmaintenanceEnables AI agents to traverse SysML v2 model graphs, query requirements, and perform impact analysis for model-based systems engineering. It allows agents to interact with plain-text models to automate documentation and refine system architectures.-
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to parse, create, update, delete, and search natural language specification elements in markdown files via MCP tools.1MIT
- AlicenseNot gradedqualityCmaintenanceEnables local-first import of Markdown/TXT/JSON/CSV requirements into per-project SQLite, letting Codex query requirements, dependencies, and impact through MCP and a local web UI.14 npmMIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to query read-only requirements and test data to find uncovered requirements, failing tests, coverage summaries, and qualification reports through MCP tools.MIT