Repository navigation
Align MCP tool descriptions with local agent guidance - #1079
Conversation
Key gaps closed between what external LLMs (via MCP) and the local agent
are told about how to use NodeSpace tools correctly.
initialize.rs — two new instruction sections:
- SCHEMA CREATION RULES: no name/title fields, enum coreValues format,
targetType must be an existing type, prefer relationships over arrays
- SEARCH FIRST: always search before fetching/updating by ID; never use
guessed IDs
tools.rs (create_schema):
- Tool description now dynamic: includes current node_type_enum so
external LLMs see the same available types list as create_node already
does
- FIELDS section: explicit "no name/title" rule + title_template exception
- coreValues field added to enum fields (same as local agent tools.rs)
- RELATIONSHIPS: targetType description now says "MUST be an existing type
— do NOT invent types that don't exist yet"
- title_template description: clarified that {name} token requires a 'name'
field to be defined
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Code Review SummaryThis is a focused, high-signal change. It closes the information-asymmetry gap between local-agent and MCP-client tooling by (a) injecting two new instruction sections into the Findings[Improvement] Instruction sections are invisible to tests — PR test plan items 2 and 3 are unverified
Minimal fix — add to let instructions = result["instructions"].as_str().unwrap();
assert!(instructions.contains("SCHEMA CREATION RULES"), "instructions must include schema creation rules");
assert!(instructions.contains("SEARCH FIRST"), "instructions must include search-first directive");Similarly, let create_schema = tools.iter().find(|t| t["name"] == "create_schema").unwrap();
assert!(create_schema["description"].as_str().unwrap().contains("text"), "create_schema description must list available types");would catch the [Improvement]
|
malibio
left a comment
There was a problem hiding this comment.
Review verdict: improvements needed before merge.
Two items should be addressed:
-
Tests do not verify the new instruction content. PR test plan items 2 and 3 are unverified —
initialize_test.rsnever asserts onresult["instructions"], andtools_test.rsnever checkscreate_schema's description for the dynamic type list. A silent regression (typo, accidental removal) would pass CI undetected. -
unwrap_or_default()produces a silent empty string. Ifnode_type_enumis somehow not an array, thecreate_schemadescription ends with"Currently available types: ."with no diagnostic. Swap for a fallback string (e.g.,"(none)") or atracing::warn!.
Both are straightforward to fix. The rest of the change is solid and ready to ship. See the prior comment for the full findings.
- Add assertions to test_initialize_success verifying SCHEMA CREATION RULES and SEARCH FIRST sections are present in initialize response; prevents silent regressions from typos or future refactors - Add test_create_schema_description_includes_type_list to verify the dynamic type list appears in create_schema description - Change unwrap_or_default() to unwrap_or_else(|| "(none)".to_string()) so an empty schema list produces "Currently available types: (none)" instead of a malformed "Currently available types: ." Addresses reviewer recommendations from PR #1079. Co-Authored-By: Claude <[email protected]>
Review AddressedBoth important findings fixed in commit 17d5208: ✅ Missing test assertions added (
✅ Silent malformed fallback hardened (
⏭️ Suggestions skipped:
All 1163 core tests pass. |
Re-Review: commit 17d5208Scope: delta since last review commit 82fd74a. Three files changed, no other files touched. Verification of Each Fix1.
2. New standalone 3. Changed to No New Issues Introduced
Verdict: both [Improvement] findings are fully and correctly addressed. Approving. |
* Align MCP tool descriptions with local agent guidance
Key gaps closed between what external LLMs (via MCP) and the local agent
are told about how to use NodeSpace tools correctly.
initialize.rs — two new instruction sections:
- SCHEMA CREATION RULES: no name/title fields, enum coreValues format,
targetType must be an existing type, prefer relationships over arrays
- SEARCH FIRST: always search before fetching/updating by ID; never use
guessed IDs
tools.rs (create_schema):
- Tool description now dynamic: includes current node_type_enum so
external LLMs see the same available types list as create_node already
does
- FIELDS section: explicit "no name/title" rule + title_template exception
- coreValues field added to enum fields (same as local agent tools.rs)
- RELATIONSHIPS: targetType description now says "MUST be an existing type
— do NOT invent types that don't exist yet"
- title_template description: clarified that {name} token requires a 'name'
field to be defined
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
* Address review: add instruction assertions and harden type list fallback
- Add assertions to test_initialize_success verifying SCHEMA CREATION
RULES and SEARCH FIRST sections are present in initialize response;
prevents silent regressions from typos or future refactors
- Add test_create_schema_description_includes_type_list to verify the
dynamic type list appears in create_schema description
- Change unwrap_or_default() to unwrap_or_else(|| "(none)".to_string())
so an empty schema list produces "Currently available types: (none)"
instead of a malformed "Currently available types: ."
Addresses reviewer recommendations from PR #1079.
Co-Authored-By: Claude <[email protected]>
---------
Co-authored-by: Claude Sonnet 4.6 <[email protected]>
Summary
Closes the gap between what external LLMs (via MCP) and the local agent are told about how to use NodeSpace tools. The local agent gets 25+ rules via seed prompt nodes; MCP clients previously got a single unstructured instructions block with basic context.
Not trying to match the local agent verbatim — MCP clients are typically smarter models. The goal is same mechanisms and same key rules, not hand-holding.
Changes
initialize.rs— two new instruction sections:name/titlefields (withtitle_templateexception), enumcoreValuesformat,targetTypemust be an existing type ID, prefer relationships over array fieldstools.rs—create_schematool:node_type_enumlist so external LLMs see the same available types thatcreate_nodealready exposes — no need to callget_all_schemasjust to know what types existfieldsdescription: explicit "no name/title" rule withtitle_templateexceptioncoreValuesfield added to enum field items (matches local agenttools.rs)relationships.targetType: "MUST be an existing type — do NOT invent types that don't exist yet"title_template: clarified that{name}token requires anamefield to be definedTest plan
cargo test -p nodespace-corepassesinitializehandler returns updated instructions with SCHEMA CREATION RULES and SEARCH FIRST sectionstools/listresponse forcreate_schemaincludes current type IDs in descriptioncreate_schemacalled with inventedtargetTypestill fails at handler level (validation unchanged)🤖 Generated with Claude Code