-
Notifications
You must be signed in to change notification settings - Fork 384
Open
Labels
T-bugBug fixes and error correctionsBug fixes and error corrections
Description
Describe the bug
Using the macro #[tool_router(router = tool_router_read, vis = pub)]
gives the error expected an expression
. The error disappears if , vis = pub
is removed.
To Reproduce
Steps to reproduce the behavior:
tree -I target
output:
├── AGENTS.md
├── Cargo.lock
├── Cargo.toml
├── crush.json
├── expanded
├── README
├── sample_config.json
└── src
├── config.rs
├── lsp
│ ├── client.rs
│ └── mod.rs
├── main.rs
└── mcp
├── mod.rs
├── server.rs
└── tools
├── mod.rs
└── read.rs
- In
server.rs
:
#[derive(Clone)]
pub struct MCPServerConfig {
pub project_root: PathBuf,
}
#[derive(Clone)]
pub struct MCPServer {
pub(crate) tool_router: ToolRouter<Self>,
pub(crate) config: MCPServerConfig,
pub(crate) lsp_server: LSPServerSocket,
}
impl MCPServer {
pub fn new(config: MCPServerConfig, lsp_server: LSPServerSocket) -> Self {
Self {
config,
lsp_server,
tool_router: Self::tool_router_read(),
}
}
}
#[tool_handler]
impl MCPServerHandler for MCPServer {
fn get_info(&self) -> ServerInfo {
// ...
}
}
- In read.rs:
#[derive(Debug, serde::Deserialize, schemars::JsonSchema)]
pub struct ReadToolArgs {
pub path: PathBuf,
pub range_start: usize,
pub range_end: usize,
}
#[derive(Debug, serde::Serialize)]
pub struct ReadToolOutput {
pub content: Option<String>,
pub diagnostics: DocumentDiagnosticReportResult,
}
#[tool_router(router = tool_router_read, vis = pub)] // <-- error appears here, "expected an expression"
impl MCPServer {
#[tool]
pub async fn read(
&self,
Parameters(args): Parameters<ReadToolArgs>,
) -> Result<CallToolResult, MCPError> {
// ...
}
}
Expected behavior
The code compiles and produces a method MCPServer::tool_router_read
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
T-bugBug fixes and error correctionsBug fixes and error corrections