feat(component2json, wassette): normalize WIT function name to be compatible with MCP Tool name#57
Conversation
Contributor
There was a problem hiding this comment.
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
FunctionIdentifierandToolMetadatato 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();
asw101
reviewed
Aug 3, 2025
…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>
Member
|
LGTM 🎉 |
Copilot AI
added a commit
that referenced
this pull request
Oct 22, 2025
After thorough analysis with valid WIT files, determined that: - Valid WIT names cannot collide with current normalization - Hyphens are preserved, preventing collisions - Issue #57 was theoretical, not practical - Added test demonstrating no collisions with valid names - Added comprehensive documentation in docs/design/ Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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