modelcontextprotocol/servers · error · ValueError

Missing required arguments

Error message

Missing required arguments

What it means

The convert_time branch (server.py:196-201) requires all three keys source_timezone, time, target_timezone to be present; if any is missing it raises ValueError('Missing required arguments'). As with 46, the outer handler (error 49) re-wraps this, so the specific message is hidden from the client.

Source

Thrown at src/time/src/mcp_server_time/server.py:201

    async def call_tool(
        name: str, arguments: dict
    ) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
        """Handle tool calls for time queries."""
        try:
            match name:
                case TimeTools.GET_CURRENT_TIME.value:
                    timezone = arguments.get("timezone")
                    if not timezone:
                        raise ValueError("Missing required argument: timezone")

                    result = time_server.get_current_time(timezone)

                case TimeTools.CONVERT_TIME.value:
                    if not all(
                        k in arguments
                        for k in ["source_timezone", "time", "target_timezone"]
                    ):
                        raise ValueError("Missing required arguments")

                    result = time_server.convert_time(
                        arguments["source_timezone"],
                        arguments["time"],
                        arguments["target_timezone"],
                    )
                case _:
                    raise ValueError(f"Unknown tool: {name}")

            return [
                TextContent(type="text", text=json.dumps(result.model_dump(), indent=2))
            ]

        except Exception as e:
            raise ValueError(f"Error processing mcp-server-time query: {str(e)}")

    options = server.create_initialization_options()
    async with stdio_server() as (read_stream, write_stream):

View on GitHub (pinned to 76d64c822f)

Solutions

  1. Include all three keys: source_timezone, time, target_timezone.
  2. Check key presence and spelling client-side against the schema before the call.
  3. Fix the outer except (error 49) to surface this message if you maintain the server.

Example fix

// before
//   {"source_timezone":"UTC","time":"12:00"}                 -> Missing required arguments
// after
//   {"source_timezone":"UTC","time":"12:00","target_timezone":"America/New_York"}
Defensive patterns

Strategy: validation

Validate before calling

required = ("source_timezone", "time", "target_timezone")
missing = [k for k in required if k not in arguments]
if missing:
    raise ValueError(f"missing required keys: {missing}")

Type guard

def has_convert_args(args: object) -> bool:
    required = ("source_timezone", "time", "target_timezone")
    return isinstance(args, dict) and all(k in args and args[k] for k in required)

Prevention

When it happens

Trigger: Calling convert_time missing one of the three required keys (most often target_timezone), or with a typo'd key name like 'source_tz' instead of 'source_timezone'.

Common situations: Client forgets a field; key-name drift from docs; LLM drops a required parameter; partial form submission.

Related errors


AI-assisted analysis of modelcontextprotocol/servers@76d64c822f (2026-08-12). Data as JSON: /api/errors/92eb64afe3fe8f43. Report an issue: GitHub.