Skip to content

Conversation

Mossaka
Copy link
Collaborator

@Mossaka Mossaka commented Aug 3, 2025

This commit normalizes the WIT exported function name to be compatible with MCP Tool name,
which requires the name to be of the form '^[a-zA-Z0-9-_]' and thus any non-alphanumeric
characters are replaced with a "_".

Closes #56

Signed-off-by: Jiaxiao Zhou duibao55328@gmail.com

@Mossaka Mossaka requested a review from Copilot August 3, 2025 19:44
Copy link
Contributor

@Copilot 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

This PR normalizes WIT function names to be compatible with MCP (Model Context Protocol) Tool naming requirements. The MCP specification requires tool names to match the pattern ^[a-zA-Z0-9-_]{1,128}$, so any non-alphanumeric characters are replaced with underscores.

  • Introduces new data structures FunctionIdentifier and ToolMetadata to track original WIT names alongside normalized MCP-compatible names
  • Replaces direct JSON schema generation with structured tool metadata that includes both original and normalized names
  • Updates the component registry to use the new tool metadata system instead of parsing tool names from JSON schemas

Reviewed Changes

Copilot reviewed 2 out of 4 changed files in this pull request and generated 2 comments.

File Description
crates/component2json/src/lib.rs Adds tool name normalization logic, validation functions, and new data structures for tracking function identifiers
crates/wassette/src/lib.rs Updates component registry to use structured tool metadata and implements function identifier lookup for tool execution
Comments suppressed due to low confidence (1)

crates/component2json/src/lib.rs:986

  • The test file path changed from 'filesystem-rs.wasm' to 'filesystem.wasm' but there's no indication this file exists. This could cause test failures if the new file doesn't exist.
        let component = Component::from_file(&engine, "testdata/filesystem.wasm").unwrap();

…patible with MCP Tool name

This commit normalizes the WIT exported function name to be compatible with MCP Tool name,
which requires the name to be of the form '^[a-zA-Z0-9-_]' and thus any non-alphanumeric
characters are replaced with a "_".

Signed-off-by: Jiaxiao Zhou <duibao55328@gmail.com>
@asw101
Copy link
Member

asw101 commented Aug 4, 2025

LGTM 🎉

@Mossaka Mossaka merged commit a80e522 into main Aug 4, 2025
5 checks passed
@Mossaka Mossaka deleted the issue56 branch August 4, 2025 03:16
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.

Tool names that do not match ^[a-zA-Z0-9_-]{1,128}$ will break Claude Code
2 participants