fix: add project parameter for mcp in container
This commit is contained in:
14
src/mcp.rs
14
src/mcp.rs
@@ -55,7 +55,8 @@ fn tool_schemas() -> Value {
|
|||||||
"text": { "type": "string", "description": "todo text" },
|
"text": { "type": "string", "description": "todo text" },
|
||||||
"priority": { "type": "string", "enum": ["low", "medium", "high", "critical"] },
|
"priority": { "type": "string", "enum": ["low", "medium", "high", "critical"] },
|
||||||
"tags": { "type": "array", "items": { "type": "string" } },
|
"tags": { "type": "array", "items": { "type": "string" } },
|
||||||
"no_project": { "type": "boolean" }
|
"no_project": { "type": "boolean" },
|
||||||
|
"project": { "type": "string", "description": "explicit project path, use when the server cannot auto-detect git repos (e.g. running in a container)" }
|
||||||
},
|
},
|
||||||
"required": ["text"]
|
"required": ["text"]
|
||||||
}
|
}
|
||||||
@@ -70,6 +71,7 @@ fn tool_schemas() -> Value {
|
|||||||
"priority": { "type": "string", "enum": ["low", "medium", "high", "critical"] },
|
"priority": { "type": "string", "enum": ["low", "medium", "high", "critical"] },
|
||||||
"search": { "type": "string" },
|
"search": { "type": "string" },
|
||||||
"here": { "type": "boolean", "description": "only show todos for current repo" },
|
"here": { "type": "boolean", "description": "only show todos for current repo" },
|
||||||
|
"project": { "type": "string", "description": "explicit project path to filter by, use when the server cannot auto-detect git repos (e.g. running in a container)" },
|
||||||
"all": { "type": "boolean", "description": "include completed todos" }
|
"all": { "type": "boolean", "description": "include completed todos" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -156,7 +158,12 @@ async fn dispatch(pool: &Pool, name: &str, args: &Value) -> Value {
|
|||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let tags = str_array(args, "tags");
|
let tags = str_array(args, "tags");
|
||||||
let no_project = args.get("no_project").and_then(|v| v.as_bool()).unwrap_or(false);
|
let no_project = args.get("no_project").and_then(|v| v.as_bool()).unwrap_or(false);
|
||||||
let project = if no_project { None } else { db::detect_project() };
|
let explicit_project = args.get("project").and_then(|v| v.as_str()).map(String::from);
|
||||||
|
let project = if no_project {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
explicit_project.or_else(db::detect_project)
|
||||||
|
};
|
||||||
db::insert_todo(pool, text, &priority, project.as_deref(), &tags)
|
db::insert_todo(pool, text, &priority, project.as_deref(), &tags)
|
||||||
.await
|
.await
|
||||||
.map(|t| serde_json::to_string(&t).unwrap())
|
.map(|t| serde_json::to_string(&t).unwrap())
|
||||||
@@ -168,7 +175,8 @@ async fn dispatch(pool: &Pool, name: &str, args: &Value) -> Value {
|
|||||||
let search = args.get("search").and_then(|v| v.as_str()).map(String::from);
|
let search = args.get("search").and_then(|v| v.as_str()).map(String::from);
|
||||||
let here = args.get("here").and_then(|v| v.as_bool()).unwrap_or(false);
|
let here = args.get("here").and_then(|v| v.as_bool()).unwrap_or(false);
|
||||||
let all = args.get("all").and_then(|v| v.as_bool()).unwrap_or(false);
|
let all = args.get("all").and_then(|v| v.as_bool()).unwrap_or(false);
|
||||||
let project = if here { db::detect_project() } else { None };
|
let explicit_project = args.get("project").and_then(|v| v.as_str()).map(String::from);
|
||||||
|
let project = explicit_project.or_else(|| if here { db::detect_project() } else { None });
|
||||||
db::list_todos(
|
db::list_todos(
|
||||||
pool,
|
pool,
|
||||||
ListFilters {
|
ListFilters {
|
||||||
|
|||||||
Reference in New Issue
Block a user