list_npcs
Retrieve a full list of non-player characters (NPCs) in your Dungeons & Dragons campaign to manage and reference them efficiently.
Instructions
List all NPCs in the current campaign.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/gamemaster_mcp/main.py:417-430 (handler)The MCP tool handler for 'list_npcs'. Decorated with @mcp.tool for registration. Fetches NPC list from storage, retrieves details for each, and formats a bullet list with names and locations.def list_npcs() -> str: """List all NPCs in the current campaign.""" npcs = storage.list_npcs() if not npcs: return "No NPCs in the current campaign." npc_list = [] for npc_name in npcs: npc = storage.get_npc(npc_name) if npc: location = f" ({npc.location})" if npc.location else "" npc_list.append(f"• {npc.name}{location}") return "**NPCs:**\n" + "\n".join(npc_list)
- Helper method in CampaignStorage class that returns the list of NPC names (keys) from the current campaign's npcs dictionary.def list_npcs(self) -> list[str]: """List all NPC names.""" if not self._current_campaign: return [] return list(self._current_campaign.npcs.keys())
- src/gamemaster_mcp/main.py:416-416 (registration)The @mcp.tool decorator registers the list_npcs function as an MCP tool.@mcp.tool