Skip to main content
Glama

list_campaigns

Retrieve all available Dungeons & Dragons campaigns to manage characters, NPCs, locations, quests, and session tracking.

Instructions

List all available campaigns.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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")]
  • The @mcp.tool decorator registers the list_campaigns function as an MCP tool with FastMCP, inferring input/output schemas from type annotations.
    @mcp.tool

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/study-flamingo/gamemaster-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server