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" },
|
||||
"priority": { "type": "string", "enum": ["low", "medium", "high", "critical"] },
|
||||
"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"]
|
||||
}
|
||||
@@ -70,6 +71,7 @@ fn tool_schemas() -> Value {
|
||||
"priority": { "type": "string", "enum": ["low", "medium", "high", "critical"] },
|
||||
"search": { "type": "string" },
|
||||
"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" }
|
||||
}
|
||||
}
|
||||
@@ -156,7 +158,12 @@ async fn dispatch(pool: &Pool, name: &str, args: &Value) -> Value {
|
||||
.unwrap_or_default();
|
||||
let tags = str_array(args, "tags");
|
||||
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)
|
||||
.await
|
||||
.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 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 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(
|
||||
pool,
|
||||
ListFilters {
|
||||
|
||||
Reference in New Issue
Block a user