list_campaigns
Retrieve all available Dungeons & Dragons campaigns to manage characters, NPCs, locations, quests, and session tracking.
Instructions
List all available campaigns.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "list_campaigns"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/gamemaster_mcp/main.py:95-110 (handler)The MCP tool handler for 'list_campaigns'. Decorated with @mcp.tool for automatic registration and schema inference. Retrieves campaigns via storage layer and formats a markdown list indicating the current campaign.
@mcp.tool def list_campaigns() -> str: """List all available campaigns.""" campaigns = storage.list_campaigns() if not campaigns: return f"❌ No campaigns found in {storage.data_dir}!" current = storage.get_current_campaign() current_name = current.name if current else None campaign_list = [] for campaign in campaigns: marker = " (current)" if campaign == current_name else "" campaign_list.append(f"• {campaign}{marker}") return "**Available Campaigns:**\n" + "\n".join(campaign_list) - Helper method in DnDStorage class that scans the campaigns directory and returns a list of campaign names by extracting JSON file stems.
def list_campaigns(self) -> list[str]: """List all available campaigns.""" campaigns_dir = self.data_dir / "campaigns" if not campaigns_dir.exists(): return [] return [f.stem for f in campaigns_dir.glob("*.json")] - src/gamemaster_mcp/main.py:95-95 (registration)The @mcp.tool decorator registers the list_campaigns function as an MCP tool with FastMCP, inferring input/output schemas from type annotations.
@mcp.tool