Skip to content

Add get_concept tool for exact ID lookup#10

Merged
0xK3vin merged 1 commit into0xK3vin:mainfrom
mikaelj:feature-get-concept
Mar 20, 2026
Merged

Add get_concept tool for exact ID lookup#10
0xK3vin merged 1 commit into0xK3vin:mainfrom
mikaelj:feature-get-concept

Conversation

@mikaelj
Copy link
Copy Markdown
Contributor

@mikaelj mikaelj commented Mar 18, 2026

Problem
The list_roots tool returns concept IDs, and the workflow expects agents to use these IDs to navigate the graph. However, there's no way to look up a concept by its ID — the only retrieval tool is understand, which embeds the query string as a 384-dim vector and performs cosine similarity search. When an agent passes a concept ID through understand, the embedding model treats it as arbitrary text, not as a key. The resulting vector may have low similarity to the concept's own embedding, causing lookups to fail.

Motivation
My tool Fuska (https://github.com/mikaelj/fuska) stores chapter plans and task definitions as megamemory concepts with well-defined slug IDs, agents are given slugs during execution and need to retrieve the exact plan concept to follow implementation steps. Semantic search is unreliable for this — a slug like chapter-03-main-c-god-object-split embeds poorly and may not match its own concept. A direct ID lookup is the only reliable path.

Solution
Add get_concept — a lightweight exact-ID lookup tool that calls the existing db.getNode(id) and buildNodeWithContext() helpers. Returns the same NodeWithContext format as understand, with children, edges, incoming edges, and parent.

What this is

  • A missing accessor for the primary key, complementary to semantic search
  • Follows the exact same patterns as all existing tools (handler, Zod schema, timeline logging)
  • ~50 lines, zero new dependencies, no existing behavior changed

What this is not

  • A replacement for understand — semantic search remains the primary discovery mechanism
  • A text search or fuzzy matching tool — it's a simple PK lookup

- Add getConcept() handler that retrieves a concept by its exact ID using db.getNode()
- Register get_concept MCP tool with Zod schema and timeline logging in index.ts
- Introduce GetConceptInput type with required id field

adhoc-plan-001
Copilot AI review requested due to automatic review settings March 18, 2026 07:28
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an exact-ID retrieval path for knowledge graph concepts so agents can reliably fetch a node when they already have its concept ID (complementing understand’s semantic search).

Changes:

  • Introduce getConcept tool handler backed by db.getNode(id) + buildNodeWithContext().
  • Register new MCP tool get_concept with timeline logging + error formatting.
  • Add dedicated getConcept test suite and document the new tool in the README.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/types.ts Adds GetConceptInput type used by the new tool.
src/tools.ts Implements getConcept exact-ID lookup returning NodeWithContext.
src/index.ts Registers the get_concept MCP tool and logs it to the timeline.
src/tests/get-concept.test.ts Adds coverage for success, missing ID, soft-deleted nodes, and context fields.
README.md Documents get_concept and updates workflow/tool counts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/types.ts
Comment on lines +130 to +132
export interface GetConceptInput {
id: string;
}
@0xK3vin 0xK3vin merged commit a11bc35 into 0xK3vin:main Mar 20, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants