Skip to content

How to specify the input arguments description for custom tools #144

@asemlucben

Description

@asemlucben

I am testing this Python SDK using the step-5-build-an-interactive-assistant to create the weather app demo but I struggle to have the LLM understand that it has to provide some input to the get_weather tool.

For example, if I define the tool as in the example:

...
@define_tool(description="Get the current weather for a city")
async def get_weather(params: dict) -> dict:
    print("weather tool called with params:", params)
    ....

The AI calls the tool without specifying any city as input, so nothing is returned:

🌤️  Weather Assistant (type 'exit' to quit)
   Try: 'What's the weather in Paris?' or 'Compare weather in NYC and LA'

You: What's the weather in Paris?
Assistant: weather tool called with params: {}
I'm unable to fetch the current weather for Paris right now due to a technical issue. Please try again later.

You: exit

While, if I specify that an input argument should be provided:

@define_tool(description="Get the current weather for a city. The city name is provided in the 'city' parameter.")
async def get_weather(params: dict) -> dict:
    print("weather tool called with params:", params)
    if params is None or "city" not in params:
        return {"error": "City parameter is required."}
    ...

Then the tool gets that something is required as input:

You: What's the weather in Paris?
Assistant: 
weather tool called with params: {}
I need to explicitly specify the city as "Paris" in the request. Let me try again with the correct parameter.
weather tool called with params: {'city': 'Paris'}
The current weather in Paris is 66°F and partly cloudy.

You: exit

Expected behavior

In other MCP server tools descriptors, like C# ModelContextProtocol you can add a description for each input argument, something like:

[McpServerTool(Name = "SummarizeContentFromUrl"), Description("Summarizes content downloaded from a specific URI")]
public static async Task<string> SummarizeDownloadedContent(
    McpServer thisServer,
    HttpClient httpClient,
    [Description("The url from which to download the content to summarize")] string url,
    CancellationToken cancellationToken)
{
    ...

Which allows the LLM to better understand the tool usage and expected parameters

Environment information

  • Windows 11
  • Python 3.14.0
  • github-copilot-sdk==0.1.16
  • GitHub Copilot CLI v0.0.392

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions