-
Notifications
You must be signed in to change notification settings - Fork 157
Open
Description
- Root cause: The list_sheets MCP tool returned a raw Python list. FastMCP serializes tool results as a single text block, so only the first sheet name survived the conversion and reached the client. That’s why the UI always showed one sheet even though the API was listing them all.
- Fix: Filter out non‑grid tabs and return a single string with sheet names separated by
\n. Example:"catalog\ncatalog (copy)\nx1". Now every tab appears correctly. - Next steps: I’m preparing an automated test case plus a PR that covers this serialization bug so we don’t regress.
Let me know if you want the draft issue text or additional logs/screenshots attached.
@mcp.tool()
def list_sheets(spreadsheet_id: str, ctx: Context = None) -> List[str]:
"""
List all sheets in a Google Spreadsheet.
Args:
spreadsheet_id: The ID of the spreadsheet (found in the URL)
Returns:
List of sheet names
"""
sheets_service = ctx.request_context.lifespan_context.sheets_service
# Get spreadsheet metadata
spreadsheet = sheets_service.spreadsheets().get(spreadsheetId=spreadsheet_id).execute()
# Extract only grid sheet names (exclude charts / data-source sheets)
sheet_names = [
sheet['properties']['title']
for sheet in spreadsheet['sheets']
if sheet.get('properties', {}).get('sheetType', 'GRID') == 'GRID'
]
# Return newline-separated sheet names as plain text
return "\n".join(sheet_names)
Metadata
Metadata
Assignees
Labels
No labels