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
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | NPC name |
Implementation Reference
- src/gamemaster_mcp/main.py:393-414 (handler)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)
- src/gamemaster_mcp/main.py:395-396 (schema)Input schema definition using Pydantic Annotated and Field for the 'name' parameter.name: Annotated[str, Field(description="NPC name")] ) -> str:
- src/gamemaster_mcp/main.py:393-393 (registration)Tool registration decorator @mcp.tool applied to the get_npc function.@mcp.tool