fix: Add explicit type annotations to MCP tool parameters by phernandez · Pull Request #394 · basicmachines-co/basic-memory · GitHub
Skip to content

fix: Add explicit type annotations to MCP tool parameters - #394

Merged
phernandez merged 2 commits into
mainfrom
claude/issue-393-20251022-1244
Nov 10, 2025
Merged

fix: Add explicit type annotations to MCP tool parameters#394
phernandez merged 2 commits into
mainfrom
claude/issue-393-20251022-1244

Conversation

@phernandez

Copy link
Copy Markdown
Member

Description

Fixes #393

This PR adds explicit type annotations to MCP tool parameters that were causing tools to be skipped by MCP clients like qwen code.

Changes

  • Add TagType annotation to write_note.tags parameter
  • Replace StringOrInt type alias with inline union type in build_context.depth
  • Ensures MCP protocol compatibility with clients that require explicit types

Root Cause

MCP clients require all tool parameters to have explicit, JSON-serializable type annotations. The issues were:

  1. write_note: The tags parameter had no type annotation (tags=None)
  2. build_context: Used Python 3.12+ type alias (type StringOrInt = str | int) which doesn't serialize to JSON schema

Testing

  • Existing tests should pass
  • Issue reporter should verify with qwen code CLI

Generated with Claude Code

Fixes #393

- Add TagType annotation to write_note.tags parameter
- Replace StringOrInt type alias with inline union type in build_context.depth
- Ensures MCP protocol compatibility with clients that require explicit types

MCP clients like qwen code were skipping these tools due to missing or
non-serializable type information in parameter schemas. All MCP tool
parameters must have explicit, JSON-serializable type annotations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Paul Hernandez <phernandez@users.noreply.github.com>
@github-actions

github-actions Bot commented Oct 22, 2025

Copy link
Copy Markdown
Contributor

Pyright doesn't allow type alias variables in function signatures.
Changed tags: TagType to tags: list[str] | str | None to match
the pattern used in build_context.py.

Fixes type checking errors across all platforms.

Signed-off-by: phernandez <paul@basicmachines.co>
@github-actions

github-actions Bot commented Nov 10, 2025

Copy link
Copy Markdown
Contributor

@phernandez
phernandez merged commit 581b7b1 into main Nov 10, 2025
16 checks passed
@phernandez
phernandez deleted the claude/issue-393-20251022-1244 branch November 10, 2025 23:02
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.

1 participant