

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
1# CLAUDE.md23This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.45## Project Overview67mcp-attrは、Model Context Protocol (MCP) サーバーを宣言的に構築するためのRustライブラリです。属性マクロを使用してMCPサーバーを簡単に作成できるように設計されています。89### Architecture1011このプロジェクトは3つのワークスペースメンバーで構成されています:1213- **mcp-attr**: メインライブラリ。MCPサーバーとクライアントの実装14- **mcp-attr-macros**: プロシージャルマクロの実装 (`#[mcp_server]`, `#[tool]`, `#[resource]`, `#[prompt]`)15- **codegen**: スキーマ生成とコード生成用のユーティリティ1617### Key Components1819- `#[mcp_server]` 属性によるMCPサーバーの宣言的記述20- `#[tool]`, `#[resource]`, `#[prompt]` 属性による機能の実装21- `#[complete_fn]` 属性による補完機能の実装(追加引数対応)22- MCPクライアント(テスト用)23- 型システムを活用したスキーマ生成2425### Completion Function Enhancement (`#[complete_fn]`)2627`#[complete_fn]` 属性に追加引数機能を実装しました:2829#### 基本的な使用方法30```rust31#[complete_fn]32async fn complete_with_args(&self, value: &str, category: &str, count: Option<u32>) -> Result<Vec<String>> {33 // 実装34}35```3637#### 対応している引数型38- `&str`: 必須文字列引数39- `Option<&str>`: オプショナル文字列引数40- `T: FromStr`: 必須の型変換可能な引数41- `Option<T: FromStr>`: オプショナルの型変換可能な引数4243#### 引数の動作44- 引数は `CompleteRequestParams::context::arguments` (BTreeMap) から取得45- オプショナル引数がない場合は `None` を返す46- 必須引数がない場合は空の補完結果を返す47- 型変換に失敗した場合はエラーを返す48- 型互換性チェックはコンパイル時に行われる4950#### テスト51- 統合テスト: `tests/completion_*.rs` のマトリックス構造テスト52- コンパイル失敗テスト: `tests/compile_fail/completion_*.rs`5354## Development Commands5556### Build and Test57```bash58# 全パッケージのビルド59cargo build6061# 特定パッケージのビルド62cargo build -p mcp-attr63cargo build -p mcp-attr-macros64cargo build -p mcp-attr-codegen6566# テスト実行67cargo test6869# 特定パッケージのテスト70cargo test -p mcp-attr7172# ドキュメントテスト73cargo test --doc7475# コンパイル失敗テスト(trybuild)76cargo test --test compile_fail -- --ignored77```7879### Code Quality80```bash81# 型チェック82cargo check8384# テストのコンパイルチェック(実行なし)85cargo test --no-run8687# Clippy(リンター)88cargo clippy8990# 自動修正91cargo clippy --fix --allow-dirty9293# ドキュメント生成94cargo doc9596# フォーマット97cargo fmt98```99100### Examples101```bash102# サンプル実行103cargo run --example char_count104cargo run --example tool_info105```106107## Testing Strategy108109### Test Organization110- `tests/` ディレクトリ: 統合テスト111- `tests/mcp_server_*.rs`: `#[mcp_server]` 属性のテスト(型ごとに1ファイル)112- `tests/compile_fail/`: コンパイル失敗テスト(trybuild使用)113- モジュール内 `tests` モジュール: 非公開項目のテスト114115### Test Guidelines116- 新機能実装時は必ずテストを作成117- 複数テスト追加時は1つずつ追加して確認118- テストデータは英語を使用(非ASCII文字テスト時を除く)119120### Debugging `#[mcp_server]` Macro121マクロのデバッグ時:1221. `#[mcp_server]` を `#[mcp_server(dump)]` に変更1232. テスト実行でマクロ展開後コードを確認1243. 展開後コードを直接編集してデバッグ1254. 修正内容をマクロ実装に反映126127## Completion Tests Structure128129### Test File Organization130131Completion functionality tests are organized in a matrix structure based on:132- **Usage context**: prompt vs resource133- **Definition location**: global (global functions) vs impl (methods in #[mcp_server] impl)134135#### Success Case Tests136```137tests/138├── completion_prompt_global.rs # Prompt + Global completion functions139├── completion_prompt_impl.rs # Prompt + Impl completion methods140├── completion_resource_global.rs # Resource + Global completion functions141├── completion_resource_impl.rs # Resource + Impl completion methods142└── completion_edge_cases.rs # Special cases not covered by the matrix143```144145#### Compile Failure Tests146Located in `tests/compile_fail/` with naming pattern: `completion_[category]_[error].rs`147148### Adding New Completion Tests149150#### For Common Functionality151When adding a new test for functionality that applies to all completion contexts:1521. **MUST add the test to all 4 matrix files** (completion_prompt_global, completion_prompt_impl, completion_resource_global, completion_resource_impl)1532. Use consistent test naming across all files1543. Only exclude from specific files if functionality is genuinely incompatible1554. Document any exclusions with clear comments156157#### For Special Cases158Use `tests/completion_edge_cases.rs` for cross-context integration tests, manual overrides, and cases that don't fit the matrix structure.159160## Code Style161162### Rust Conventions163- Rustの慣例とベストプラクティスに従う164- 関数名・型名は一貫性と対称性を重視165- 理解困難なコードのみにコメント付与166- バグ以外でErrが返されない場合はResultを使わずパニック167168### Error Handling169- `mcp_attr::Result` と `mcp_attr::Error` を使用170- `bail!` (プライベート) と `bail_public!` (パブリック) マクロを活用171- 依存関係のエラーはプライベート情報として扱う172173### Documentation174- 公開項目には適切なdocコメントを付与175- 最初の行は簡潔な1行説明176- 関連する型・関数は `[]` でリンク177- `cargo test --doc` と `cargo doc` で検証178179## Dependencies180181### Main Dependencies182- `serde`: JSON シリアライゼーション183- `tokio`: 非同期ランタイム184- `schemars`: JSON Schema生成185- `jsoncall`: JSON-RPC実装186- `uri-template-ex`: URI Template処理187188### Development Dependencies189- `trybuild`: コンパイル失敗テスト190- `pretty_assertions`: テストアサーション191192## Documentation Generation193194### tests_readme.rs (Auto-generated File)195196**IMPORTANT**: `mcp-attr/src/tests_readme.rs` is an auto-generated file and should NOT be edited directly.197198- **Source**: Generated from `README.ja.md` (Japanese README)199- **Generation Command**: `rustdoc-include --root /path/to/project`200- **When to Regenerate**:201 - After modifying README.md or README.ja.md202 - When doctest examples need updating203 - When completion function examples change204205### Workflow for Updating Documentation Examples2062071. Edit the source README file (`README.md` for English, `README.ja.md` for Japanese)2082. Run `rustdoc-include --root .` to regenerate tests_readme.rs2093. Run `cargo test --doc` to verify all doctests pass2104. Any direct edits to tests_readme.rs will be overwritten on next generation211212### rustdoc-include Usage213214```bash215# Regenerate tests_readme.rs from README files216rustdoc-include --root .217```218219This command processes files with `#![include_doc("filename", start/end)]` markers and generates documentation tests.220221## Important Notes222223- 依存関係のバージョンダウンは禁止224- カレントディレクトリ変更は避け、コマンド引数で対応225- エラー修正3回失敗時はスキップして他の箇所を修正226- 依存関係の追加・変更は禁止とし、必要な場合はユーザーによる手動編集を促すこと227- **tests_readme.rsは自動生成ファイルのため直接編集しない** - README.mdを編集してrustdoc-includeで再生成する
One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| frozenlib/mcp-attr.cursor/rules/mcp-server-attr-codegen-test.mdc · 28 | Cursor rules | no sections | 45/100 | 14 days ago | |
| frozenlib/mcp-attr.cursor/rules/rust.mdc · 28 | Cursor rules | testdocs | 56/100 | 14 days ago |
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| dotCMS/corecore-web/CLAUDE.md · 949 | CLAUDE.md | teststylearchtesting-strategy+3 | 100/100 | 14 days ago | |
| tphakala/birdnet-goCLAUDE.md · 1.6k | CLAUDE.md | buildtestlint-formatstyle+8 | 100/100 | today | |
| tyrchen/geektime-bootcamp-aiw7/genslides/backend/CLAUDE.md · 230 | CLAUDE.md | testlint-formatstylearch+6 | 100/100 | 9 days ago | |
| nimbalyst/nimbalystpackages/android/CLAUDE.md · 1.5k | CLAUDE.md | setupbuildstylearch+2 | 100/100 | 14 days ago | |
| microsoft/playwrightCLAUDE.md · 95k | CLAUDE.md | buildtestlint-formatstyle+7 | 100/100 | 7 days ago | |
| Adit-Jain-srm/NightmareNetCLAUDE.md · 46 | CLAUDE.md | buildtestlint-formatstyle+6 | 100/100 | 14 days ago | |
| stacklok/toolhiveCLAUDE.md · 2.0k | CLAUDE.md | buildteststylearch+4 | 100/100 | 14 days ago | |
| bagisto/bagistoCLAUDE.md · 28k | CLAUDE.md | setupbuildteststyle+5 | 100/100 | 7 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/frozenlib-mcp-attr-claude)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.