get_proposal_details
Fetch detailed information about a specific DAO governance proposal using its unique identifier to analyze decentralized decision-making.
Instructions
Fetch detailed information for a specific proposal.
Parameters:
proposal_id (str): The unique identifier of the proposal.
Returns:
A formatted string containing detailed information about the proposal.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| proposal_id | Yes |
Implementation Reference
- main.py:109-164 (handler)The handler function decorated with @mcp.tool() that implements the core logic for fetching and formatting detailed information about a Snapshot proposal using GraphQL query to the Snapshot API.@mcp.tool() async def get_proposal_details(proposal_id: str, ctx: Context) -> str: """ Fetch detailed information for a specific proposal. Parameters: proposal_id (str): The unique identifier of the proposal. Returns: A formatted string containing detailed information about the proposal. """ query = """ query Proposal($id: String!) { proposal(id: $id) { id title body state created end choices scores votes } } """ async with httpx.AsyncClient() as client: try: response = await client.post( SNAPSHOT_API, json={"query": query, "variables": {"id": proposal_id}} ) response.raise_for_status() data = response.json() proposal = data.get("data", {}).get("proposal") if not proposal: return "Proposal not found" created_str = ts2str(proposal['created']) end_str = ts2str(proposal['end']) return ( f"Proposal ID: {proposal['id']}\n" f"Title: {proposal['title']}\n" f"State: {proposal['state']}\n" f"Created: {created_str}\n" f"End: {end_str}\n" f"Choices: {', '.join(proposal['choices'])}\n" f"Scores: {proposal['scores']}\n" f"Votes: {proposal['votes']}\n" "------\n" f"{proposal['body']}" ) except Exception as e: return f"Error: {str(e)}"
- main.py:13-15 (helper)Helper utility function to convert Unix timestamps to readable datetime strings, used within get_proposal_details for formatting created and end times.def ts2str(ts: int) -> str: dt = datetime.fromtimestamp(ts) return dt.strftime("%Y-%m-%d %H:%M:%S")
- main.py:109-109 (registration)The @mcp.tool() decorator registers the get_proposal_details function as an MCP tool.@mcp.tool()