Skip to content

Commit bd2a3f4

Browse files
committed
Fix claude permissions MCP endpoint
1 parent fe2a062 commit bd2a3f4

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

crates/but-claude/src/mcp.rs

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,8 @@ use rmcp::{
88
},
99
schemars, tool,
1010
};
11-
use tracing_subscriber::{self, EnvFilter};
1211

1312
pub async fn start() -> Result<()> {
14-
tracing_subscriber::fmt()
15-
.with_env_filter(EnvFilter::from_default_env().add_directive(tracing::Level::DEBUG.into()))
16-
.with_writer(std::io::stderr)
17-
.with_ansi(false)
18-
.init();
19-
20-
tracing::info!("Starting MCP server");
21-
2213
let client_info = Arc::new(Mutex::new(None));
2314
let transport = (tokio::io::stdin(), tokio::io::stdout());
2415
let service = Mcp::default().serve(transport).await?;
@@ -35,12 +26,12 @@ pub struct Mcp {}
3526

3627
#[tool(tool_box)]
3728
impl Mcp {
38-
#[tool(description = "Permission check - approve if the input contains allow, otherwise deny.")]
29+
#[tool(description = "Permission check for tool calls")]
3930
pub fn approval_prompt(
4031
&self,
41-
#[tool(aggr)] request: PermissionRequest,
32+
#[tool(aggr)] request: McpPermissionRequest,
4233
) -> Result<CallToolResult, McpError> {
43-
let result = Ok(PermissionResponse {
34+
let result = Ok(McpPermissionResponse {
4435
behavior: Behavior::Allow,
4536
updated_input: Some(request.input),
4637
message: None,
@@ -49,9 +40,8 @@ impl Mcp {
4940
}
5041
}
5142

52-
#[derive(Debug, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
53-
#[serde(rename_all = "camelCase")]
54-
pub struct PermissionRequest {
43+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
44+
pub struct McpPermissionRequest {
5545
#[schemars(description = "The name of the tool requesting permission")]
5646
tool_name: String,
5747
#[schemars(description = "The input for the tool")]
@@ -60,17 +50,17 @@ pub struct PermissionRequest {
6050
tool_use_id: String,
6151
}
6252

63-
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, strum::Display)]
53+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
6454
pub enum Behavior {
65-
#[strum(serialize = "allow")]
55+
#[serde(rename = "allow")]
6656
Allow,
67-
#[strum(serialize = "deny")]
57+
#[serde(rename = "deny")]
6858
Deny,
6959
}
7060

7161
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
7262
#[serde(rename_all = "camelCase")]
73-
pub struct PermissionResponse {
63+
pub struct McpPermissionResponse {
7464
behavior: Behavior,
7565
updated_input: Option<serde_json::Value>,
7666
message: Option<String>,

0 commit comments

Comments
 (0)