Skip to content

Conversation

@cokun-figma
Copy link

Summary

Added tool name alias support to allow MCP servers to maintain backwards compatibility when renaming tools. Aliases resolve to registered tools at call time but are not included in tools/list responses.

Motivation and Context

When servers need to rename tools (e.g., expanding get_temperature to get_weather), clients using the old tool name would break. Tool aliases provide a server-side fallback mechanism that:

  • Maintains backwards compatibility with clients using old tool names
  • Keeps the tools list clean (aliases don't appear in tools/list)
  • Allows multiple legacy names to point to the same tool
  • Respects the target tool's enabled/disabled state and validation

How Has This Been Tested?

Comprehensive test suite added with 7 passing tests covering:

  • ✅ Calling an alias executes the target tool
  • ✅ Aliases don't appear in tools/list responses
  • ✅ Unknown tool names throw appropriate errors
  • ✅ Aliasing non-existent tools throws errors
  • ✅ Multiple aliases can point to the same tool
  • ✅ Disabled tools are inaccessible via aliases
  • ✅ Argument validation works correctly through aliases

All tests pass: npm test -- src/server/mcp.test.ts --testNamePattern="aliasTool"

Breaking Changes

None. This is a fully backwards-compatible additive feature.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

API Design:

// Register the tool with its new name
server.registerTool('get_weather', config, handler);

// Create alias for backwards compatibility
server.aliasTool('get_temperature', 'get_weather');

Implementation:

  • Added _toolAliases: Map<string, string> to track alias → target mappings
  • Added aliasTool(aliasName: string, targetName: string): void public method
  • Modified CallToolRequestSchema handler to resolve aliases after direct lookup fails
  • Aliases are TypeScript-only; never serialized to the wire

Documentation:

  • Added "Tool Aliases" section under "Backwards Compatibility" in README
  • Includes clear example with get_temperatureget_weather
  • Documents key features: call-time resolution, multiple aliases support, enabled/disabled state respect

@cokun-figma cokun-figma marked this pull request as ready for review October 16, 2025 14:02
@cokun-figma cokun-figma requested a review from a team as a code owner October 16, 2025 14:02
* @param targetName - The canonical tool name to resolve to
* @throws Error if the canonical tool does not exist
*/
aliasTool(aliasName: string, targetName: string): void {

Choose a reason for hiding this comment

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

should we support a list of alias names string[] that we can map to targetName, this might enable us more flexibility in the future

@felixweinberger felixweinberger self-assigned this Oct 16, 2025
@felixweinberger felixweinberger added the enhancement Request for a new feature that's not currently supported label Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Request for a new feature that's not currently supported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants