Handle HTTP tool selectors without explicit verb

This commit is contained in:
Peter Steinberger 2025-11-07 03:19:49 +00:00
parent c3168a848d
commit ac067aca0a
2 changed files with 15 additions and 1 deletions

View File

@ -26,7 +26,15 @@ export function looksLikeHttpUrl(value?: string): boolean {
}
export function splitHttpToolSelector(input: string): { baseUrl: string; tool: string } | null {
const normalized = normalizeHttpUrlCandidate(input);
const trimmed = input.trim();
const candidate = (() => {
const openParen = trimmed.indexOf('(');
if (openParen === -1) {
return trimmed;
}
return trimmed.slice(0, openParen);
})();
const normalized = normalizeHttpUrlCandidate(candidate);
if (!normalized) {
return null;
}

View File

@ -42,6 +42,12 @@ describe('command inference', () => {
expect(result).toEqual({ kind: 'command', command: 'call', args: [token, 'limit=1'] });
});
it('routes HTTP tool expressions with arguments directly to call', () => {
const token = 'https://api.example.com/mcp.getStatus(component: "foo")';
const result = inferCommandRouting(token, [], definitions);
expect(result).toEqual({ kind: 'command', command: 'call', args: [token] });
});
it('suggests names when edit distance is large', () => {
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
const result = inferCommandRouting('unknown', [], definitions);