[BUG] Single mode: an unknown tool name fails with "An error occurred invoking 'azure'" instead of listing the available tools

Aperta Adatta ai principianti
#4,235 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@Ahmed-Manai ci sta già lavorando.

Dal 25/11/2026.

  • #4236 di @Ahmed-Manai — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
csharp
Ambito
backend

Direzione di ricerca

Inizia da SingleProxyToolLoader.GetToolsInGroupAsync, dove la KeyNotFoundException proveniente da IMcpDiscoveryStrategy.GetOrCreateClientAsync viene rilanciata per un nome di strumento sconosciuto. Confrontala con il ramo IsNamespaceAllowed false, che restituisce una lista vuota, e verifica come CommandModeAsync e ToolLearnModeAsync usano quella lista vuota. È completato quando uno strumento sconosciuto restituisce la lista degli strumenti radice, come già verifica il test CallToolHandler_WithDisabledNamespace_DoesNotLearnOrExecute per i namespace disabilitati, e la telemetria di ToolArea e ToolName resta Unknown.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

server-Azure.Mcp

Describe the bug

In single mode (server start --mode single), calling the azure tool with a tool name that doesn't exist fails with an opaque error. The model gets nothing it can use to correct the call:

An error occurred invoking 'azure'.

SingleProxyToolLoader.GetToolsInGroupAsync rethrows the KeyNotFoundException from IMcpDiscoveryStrategy.GetOrCreateClientAsync. Its callers already have a fallback for "no tools in this group": CommandModeAsync and ToolLearnModeAsync return the root list of available tools when the list is empty. That fallback is used for a namespace that isn't enabled (CallToolHandler_WithDisabledNamespace_DoesNotLearnOrExecute), but an unknown name throws before it can run. The Azure server always has a discovery strategy (for the registry servers), so this is the path every unknown name takes.

Namespace mode handles the same mistake well: an unknown command returns "The command '...' is not available for the 'aks' tool. Available commands: ...".

To reproduce

Azure.Mcp.Server 4.0.0-beta.10 and main (6dd224f), started with dnx Azure.Mcp --prerelease --yes -- server start --mode single:

{ "intent": "get node pool", "tool": "nope", "command": "nodepool_get", "parameters": {} }

Result: isError: true, An error occurred invoking 'azure'.

The same happens with "learn": true.

Expected behavior

An unknown tool gets the same answer as a namespace that is not enabled: the list of available tools, so the model can pick a valid one. The ToolArea and ToolName telemetry tags stay Unknown, as they are today.

Possible fix

Return an empty list from GetToolsInGroupAsync for an unknown name instead of throwing, as it already does when IsNamespaceAllowed is false. I have a PR ready with the updated test.

Lingua principale
C#
Stelle
3.9k
Fork
689
Merge medio
2g 11h
PR unite (30g)
143

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/mcp

Tutte le issue di microsoft/mcp

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.