claude_cli+codemode: MCP prompt points at codemode; MCP tools listed first in codemode
This commit is contained in:
1 parent
93bd2693c5
commit
fa0ff339f6
4 files changed
+26
-4
No files matched your search
@@ -395,10 +395,19 @@ impl Hub {
|
||||
}
|
||||
|
||||
pub fn system_prompt(&self) -> String {
|
||||
self.system_prompt_for(false)
|
||||
}
|
||||
|
||||
/// `via_codemode`: the model cannot call `mcp_*` directly (claude_cli exposes only `codemode`).
|
||||
pub fn system_prompt_for(&self, via_codemode: bool) -> String {
|
||||
let idx = self.index();
|
||||
let mut s = String::new();
|
||||
if !idx.is_empty() {
|
||||
s.push_str("# MCP tools\nCall with `mcp_call` (server, tool, arguments). Use `mcp_describe` first to get the argument schema.\n");
|
||||
s.push_str(if via_codemode {
|
||||
"# MCP tools\nNot top-level tools: reach them only through `codemode`. Inside a script: `await tools.mcp_call({server, tool, arguments})`; `await tools.mcp_describe({server, tool})` gives the argument schema (also `tools.mcp_read({server, uri})`).\n"
|
||||
} else {
|
||||
"# MCP tools\nCall with `mcp_call` (server, tool, arguments). Use `mcp_describe` first to get the argument schema.\n"
|
||||
});
|
||||
for (_, b) in idx {
|
||||
s.push_str(&b);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,12 @@ async fn stdio_lazy_index_describe_call() {
|
||||
let sp = h.system_prompt();
|
||||
assert!(sp.contains("- f.echo: Echo a message back\n"), "{sp}");
|
||||
assert!(!sp.contains("second line"));
|
||||
let cm = h.system_prompt_for(true);
|
||||
assert!(
|
||||
cm.contains("only through `codemode`") && cm.contains("- f.echo:"),
|
||||
"{cm}"
|
||||
);
|
||||
assert!(!sp.contains("codemode"));
|
||||
assert!(sp.contains("mem://notes") && sp.contains("Use echo for tests."));
|
||||
let st = h.status();
|
||||
assert!(
|
||||
|
||||
Reference in new issue
Block a user