✨ feat(kebab-mcp): schema tool (fb-30)
First tool wired — `schema` (no input args, returns schema.v1 JSON mirroring `kebab schema --json`). Establishes the per-tool module pattern (crates/kebab-mcp/src/tools/<name>.rs) + error helper that maps anyhow::Error to MCP CallToolResult.error with error.v1 content. Dispatch pattern: manual dispatch — explicit `list_tools` + `call_tool` overrides on `impl ServerHandler for KebabHandler` with a `match request.name.as_ref()` arm per tool. No proc-macro magic. Tasks 5-7 should add a new arm + new tools/<name>.rs following the same pattern; also add a `Tool::new(...)` entry in `list_tools`. API shapes confirmed from rmcp 1.6 source: - Content = Annotated<RawContent>; text via `Content::text(s)`; pattern match via `&content.raw` → `RawContent::Text(t)` → `t.text` - CallToolResult::success(Vec<Content>) / ::error(Vec<Content>) - ListToolsResult::with_all_items(Vec<Tool>) - schema_for_empty_input() from rmcp::handler::server::common Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
6
crates/kebab-mcp/src/tools/mod.rs
Normal file
6
crates/kebab-mcp/src/tools/mod.rs
Normal file
@@ -0,0 +1,6 @@
|
||||
//! Tool implementations — one module per tool.
|
||||
|
||||
pub mod schema;
|
||||
// pub mod doctor; // wired in Plan Task 5
|
||||
// pub mod search; // wired in Plan Task 6
|
||||
// pub mod ask; // wired in Plan Task 7
|
||||
22
crates/kebab-mcp/src/tools/schema.rs
Normal file
22
crates/kebab-mcp/src/tools/schema.rs
Normal file
@@ -0,0 +1,22 @@
|
||||
//! `schema` tool — wraps `kebab_app::schema_with_config`.
|
||||
//! Input: {} (no args). Output: schema.v1 JSON.
|
||||
|
||||
use rmcp::model::CallToolResult;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use schemars::JsonSchema;
|
||||
|
||||
use crate::error::{to_tool_error, to_tool_success};
|
||||
use crate::state::KebabAppState;
|
||||
|
||||
#[derive(Debug, Default, Deserialize, Serialize, JsonSchema)]
|
||||
pub struct SchemaInput {}
|
||||
|
||||
pub fn handle(state: &KebabAppState, _input: SchemaInput) -> CallToolResult {
|
||||
match kebab_app::schema_with_config(&state.config) {
|
||||
Ok(report) => match serde_json::to_string(&report) {
|
||||
Ok(json) => to_tool_success(json),
|
||||
Err(e) => to_tool_error(&anyhow::anyhow!(e)),
|
||||
},
|
||||
Err(e) => to_tool_error(&e),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user