Skip to content

list_accessible_customers returns concatenated string instead of proper array #13

@PhilipJohnBasile

Description

@PhilipJohnBasile

Description

The list_accessible_customers tool returns a List[str] which the FastMCP framework converts into multiple separate content items. When Claude processes this, it
concatenates them into a single string without delimiters.

Expected behavior

Response should be parseable as separate customer IDs:

["1234567890", "2345678901", "3456789012"]

Actual behavior

Claude sees:

123456789023456789013456789012

Root cause

Looking at the MCP server logs, the response is:

{
  "content": [
    {"type":"text","text":"1234567890"},
    {"type":"text","text":"2345678901"},
    {"type":"text","text":"3456789012"}
  ],
  "structuredContent": {
    "result": ["1234567890","2345678901","3456789012"]
  }
}

The structuredContent.result is correct, but the content array has multiple text items which get concatenated.

Suggested fix

In ads_mcp/tools/core.py, return a JSON-formatted string instead of a list:

@mcp.tool()
def list_accessible_customers() -> str:
    """Returns ids of customers directly accessible by the user authenticating the call."""
    ga_service = utils.get_googleads_service("CustomerService")
    accessible_customers = ga_service.list_accessible_customers()
    customer_ids = [
        cust_rn.removeprefix("customers/")
        for cust_rn in accessible_customers.resource_names
    ]
    import json
    return json.dumps({"customer_ids": customer_ids, "count": len(customer_ids)}, indent=2)

Environment

  • google-ads-mcp version: 0.0.1
  • Claude Desktop on Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions