Skip to content

Commit 9bdd25e

Browse files
author
Danielle Jenkins
committed
Add support for the crate name in the item-path
1 parent 704c733 commit 9bdd25e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/tools/docs/docs.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,13 @@ impl DocRouter {
147147
}
148148

149149
// Get documentation for a specific item in a crate
150-
async fn lookup_item(&self, crate_name: String, item_path: String, version: Option<String>) -> Result<String, ToolError> {
150+
async fn lookup_item(&self, crate_name: String, mut item_path: String, version: Option<String>) -> Result<String, ToolError> {
151+
// Strip crate name prefix from the item path if it exists
152+
let crate_prefix = format!("{}::", crate_name);
153+
if item_path.starts_with(&crate_prefix) {
154+
item_path = item_path[crate_prefix.len()..].to_string();
155+
}
156+
151157
// Check cache first
152158
let cache_key = if let Some(ver) = &version {
153159
format!("{}:{}:{}", crate_name, ver, item_path)
@@ -305,7 +311,7 @@ impl mcp_server::Router for DocRouter {
305311
},
306312
"item_path": {
307313
"type": "string",
308-
"description": "Path to the item (e.g., 'std::vec::Vec')"
314+
"description": "Path to the item (e.g., 'vec::Vec' or 'crate_name::vec::Vec' - crate prefix will be automatically stripped)"
309315
},
310316
"version": {
311317
"type": "string",

0 commit comments

Comments
 (0)