Skip to content

Conversation

@rabi
Copy link
Contributor

@rabi rabi commented Dec 28, 2025

Summary

Use bracket notation for tool calls to support tool names that are not
valid JS identifiers (e.g. names with hyphens like 'search-flight'):

    - server["tool"]({ ... }) syntax for all tools
    - import * as server from "server" for imports

Also export a namespace object with the server's name. Models sometimes
use named imports (import { github }) when the module only exported
individual tool functions, causing 'could not find export' errors.
Adding the server name as a named export makes both styles work:

    - import * as github from "github"; github["tool"]({})
    - import { github } from "github"; github["tool"]({})

Type of Change

  • Feature
  • Bug fix
  • Refactor / Code quality
  • Performance improvement
  • Documentation
  • Tests
  • Security fix
  • Build / Release
  • Other (specify below)

AI Assistance

  • This PR was created or reviewed with AI assistance

Testing

Unit tested and tested with mcp using tool names with hyphen.

@rabi rabi force-pushed the hyphenated-toolnames branch 3 times, most recently from 2fd7d2c to 901b173 Compare December 31, 2025 13:18
@rabi rabi changed the title fix(code-execution): sanitize hyphenated tool names to valid JS identifiers fix(code-execution): use consistent bracket notation for all tool calls Dec 31, 2025
Use bracket notation for tool calls to support tool names that are not
valid JS identifiers (e.g. names with hyphens like 'search-flight'):
- server["tool"]({ ... }) syntax for all tools
- import * as server from "server" for imports

Also export a namespace object with the server's name. Models sometimes
use named imports (import { github }) when the module only exported
individual tool functions, causing 'could not find export' errors.
Adding the server name as a named export makes both styles work:
- import * as github from "github"; github["tool"]({})
- import { github } from "github"; github["tool"]({})

Signed-off-by: rabi <[email protected]>
@rabi rabi force-pushed the hyphenated-toolnames branch from 901b173 to a58f285 Compare January 1, 2026 04:04
@rabi rabi changed the title fix(code-execution): use consistent bracket notation for all tool calls fix(code-execution): support bracket notation and multiple import styles Jan 1, 2026
@jamadeo jamadeo requested a review from alexhancock January 5, 2026 18:48
Copy link
Collaborator

@jamadeo jamadeo left a comment

Choose a reason for hiding this comment

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

Makes sense to me -- @alexhancock any reason not to do this?

@alexhancock
Copy link
Collaborator

agree, makes sense. merging. thanks for the contribution!

@alexhancock alexhancock merged commit ddaedd8 into block:main Jan 5, 2026
18 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