gitea_api_call tool body parameter validation fails with JSON objects #1

Closed
opened 2025-12-26 12:54:28 -06:00 by b3nw · 2 comments
Owner

Bug Description

The gitea_api_call tool fails when passing a JSON body parameter. The tool expects the body parameter to be a string, but when an MCP client passes a JSON-like string, it gets parsed as a Python dict before reaching the tool, causing a validation error.

Error Message

1 validation error for call[gitea_api_call]
body
  Input should be a valid string [type=string_type, input_value={'name': 'n8n-mcp-custom'...lse, 'auto_init': False}, input_type=dict]

Steps to Reproduce

  1. Use any MCP client to call gitea_api_call
  2. Pass a body parameter like: {"name": "test-repo", "private": false}
  3. The tool fails with the validation error above

Expected Behavior

The tool should accept the body as a JSON string and parse it internally, as shown in the tool definition:

@mcp.tool()
async def gitea_api_call(
    endpoint: str,
    method: str = "GET",
    params: str = "{}",
    body: str = "{}",
) -> str:

Actual Behavior

The MCP framework (or FastMCP) appears to be parsing the JSON string into a dict before the tool receives it, causing the type validation to fail.

Workaround

Use curl or other HTTP clients directly to call the Gitea API.

Environment

  • gitea-mcp-custom (latest)
  • FastMCP 2.x
  • Called via OpenCode MCP client

Possible Fix

The tool signature may need to accept Union[str, dict] for the body parameter, or the FastMCP/MCP client integration needs to preserve string types for parameters that look like JSON.

## Bug Description The `gitea_api_call` tool fails when passing a JSON body parameter. The tool expects the `body` parameter to be a string, but when an MCP client passes a JSON-like string, it gets parsed as a Python dict before reaching the tool, causing a validation error. ## Error Message ``` 1 validation error for call[gitea_api_call] body Input should be a valid string [type=string_type, input_value={'name': 'n8n-mcp-custom'...lse, 'auto_init': False}, input_type=dict] ``` ## Steps to Reproduce 1. Use any MCP client to call `gitea_api_call` 2. Pass a body parameter like: `{"name": "test-repo", "private": false}` 3. The tool fails with the validation error above ## Expected Behavior The tool should accept the body as a JSON string and parse it internally, as shown in the tool definition: ```python @mcp.tool() async def gitea_api_call( endpoint: str, method: str = "GET", params: str = "{}", body: str = "{}", ) -> str: ``` ## Actual Behavior The MCP framework (or FastMCP) appears to be parsing the JSON string into a dict before the tool receives it, causing the type validation to fail. ## Workaround Use `curl` or other HTTP clients directly to call the Gitea API. ## Environment - gitea-mcp-custom (latest) - FastMCP 2.x - Called via OpenCode MCP client ## Possible Fix The tool signature may need to accept `Union[str, dict]` for the body parameter, or the FastMCP/MCP client integration needs to preserve string types for parameters that look like JSON.
b3nw closed this issue 2025-12-26 14:03:12 -06:00
Author
Owner

Bug fix verified! The gitea_api_call tool now correctly handles both string and dict parameters for body and params. Testing complete.

Bug fix verified! The gitea_api_call tool now correctly handles both string and dict parameters for body and params. Testing complete.
Author
Owner

Additional test: String parameter format also works correctly!

Additional test: String parameter format also works correctly!
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: b3nw/gitea-mcp-custom#1