Skip to main content
Glama

get_npc

Retrieve detailed information about non-player characters in Dungeons & Dragons campaigns by specifying their name.

Instructions

Get NPC information.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesNPC name

Implementation Reference

  • The primary handler function for the 'get_npc' MCP tool. Registered via @mcp.tool decorator. Retrieves NPC data from storage and returns formatted string information.
    @mcp.tool def get_npc( name: Annotated[str, Field(description="NPC name")] ) -> str: """Get NPC information.""" npc = storage.get_npc(name) if not npc: return f"NPC '{name}' not found." npc_info = f"""**{npc.name}** (`{npc.id}`) **Race:** {npc.race or 'Unknown'} **Occupation:** {npc.occupation or 'Unknown'} **Location:** {npc.location or 'Unknown'} **Attitude:** {npc.attitude or 'Neutral'} **Description:** {npc.description or 'No description available.'} **Bio:** {npc.bio or 'No bio available.'} **Notes:** {npc.notes or 'No additional notes.'} """ return npc_info
  • Helper method in DnDStorage class that retrieves an NPC object by name from the current campaign's NPC dictionary.
    def get_npc(self, name: str) -> NPC | None: """Get an NPC by name.""" if not self._current_campaign: return None return self._current_campaign.npcs.get(name)
  • Input schema definition using Pydantic Annotated and Field for the 'name' parameter.
    name: Annotated[str, Field(description="NPC name")] ) -> str:
  • Tool registration decorator @mcp.tool applied to the get_npc function.
    @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