Skip to main content
Glama

list_npcs

Retrieve all non-player characters in your current D&D campaign to manage NPCs and track campaign details.

Instructions

List all NPCs in the current campaign.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The primary handler for the 'list_npcs' MCP tool. Decorated with @mcp.tool for automatic registration in FastMCP. Retrieves NPC list from storage, enriches with location info, and returns a formatted markdown list.
    @mcp.tool 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 DnDStorage class that returns the keys (names) of NPCs in 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())
  • The @mcp.tool decorator registers the list_npcs function as an MCP tool in the FastMCP server.
    @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