list_campaigns
Retrieve a full list of campaigns from the Dungeons & Dragons MCP Server to manage characters, NPCs, locations, quests, and session tracking efficiently.
Instructions
List all available campaigns.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/gamemaster_mcp/main.py:95-110 (handler)MCP tool handler for 'list_campaigns'. Lists all campaigns from storage, marks the current one, and formats as a markdown list.@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 (JSON file stems). Called by the main handler.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")]