Skip to content

Prompt functions return raw dicts, incompatible with fastmcp >= 3.x #496

@jslitzkerttcu

Description

@jslitzkerttcu

Bug

All five prompt functions in prompts.py return list[dict] (e.g., [{"role": "user", "content": "..."}]), but fastmcp >= 3.x requires each item in the list to be a Message object or str.

Version: code-review-graph 2.3.3, fastmcp 3.3.1

Error

Calling any MCP prompt (e.g., architecture_map) throws:

McpError: MCP error 0: Error rendering prompt 'architecture_map':
messages[0] must be Message or str, got dict.
Use Message({'role': 'user', 'content': '...'}) to wrap the value.

The error originates from fastmcp/prompts/base.py line ~310, where the _resolve method iterates the returned list and only accepts Message or str instances.

Root Cause

prompts.py returns plain dicts:

def architecture_map_prompt() -> list[dict]:
    return [
        {
            "role": "user",
            "content": "...",
        }
    ]

This worked with older fastmcp versions that accepted raw dicts, but fastmcp 3.x tightened the contract.

Fix

Import Message from fastmcp and wrap each dict:

from fastmcp.prompts import Message

def architecture_map_prompt() -> list[Message]:
    return [
        Message("...", role="user")
    ]

Same change needed for all five functions: review_changes_prompt, architecture_map_prompt, debug_issue_prompt, onboard_developer_prompt, pre_merge_check_prompt — plus the corresponding wrapper functions in main.py.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions