manage_location
Create, update, and organize locations with connections for party navigation in role-playing games. Supports lighting, hazards, tags, and connection types like doors, stairs, and portals.
Instructions
Manage location graph for party navigation. Operations: create (new location), get (retrieve location + connections), update (modify properties), delete (remove location), link (connect two locations), unlink (disconnect locations), list (all locations). Supports location types, lighting, hazards, tags, and connection types (door, passage, stairs, ladder, portal, hidden).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| operation | No | ||
| name | No | ||
| description | No | ||
| locationType | No | ||
| lighting | No | ||
| hazards | No | ||
| tags | No | ||
| terrain | No | ||
| size | No | ||
| discovered | No | ||
| properties | No | ||
| locationId | No | ||
| fromLocationId | No | ||
| toLocationId | No | ||
| connectionType | No | passage | |
| locked | No | ||
| lockDC | No | ||
| hidden | No | ||
| findDC | No | ||
| oneWay | No | ||
| filterTag | No | ||
| filterType | No |
Implementation Reference
- src/registry.ts:1040-1057 (registration)Registration of the 'manage_location' tool in the central registry. Imports manageLocation and manageLocationSchema from './modules/data.ts', defines inputSchema using toJsonSchema, and provides a wrapper handler that calls the actual manageLocation function with error handling.manage_location: { name: 'manage_location', description: 'Manage location graph for party navigation. Operations: create (new location), get (retrieve location + connections), update (modify properties), delete (remove location), link (connect two locations), unlink (disconnect locations), list (all locations). Supports location types, lighting, hazards, tags, and connection types (door, passage, stairs, ladder, portal, hidden).', inputSchema: toJsonSchema(manageLocationSchema), handler: async (args) => { try { const result = await manageLocation(args); return result; } catch (err) { if (err instanceof z.ZodError) { const messages = err.errors.map(e => `${e.path.join('.')}: ${e.message}`).join(', '); return error(`Validation failed: ${messages}`); } const message = err instanceof Error ? err.message : String(err); return error(message); } }, },
- src/modules/data.ts:255-263 (schema)Zod schema for 'manage_location' tool input validation. Discriminated union based on 'operation' field supporting create, get, update, delete, link, unlink, list operations with specific fields for each.export const manageLocationSchema = z.discriminatedUnion('operation', [ createOperationSchema, getOperationSchema, updateOperationSchema, deleteOperationSchema, linkOperationSchema, unlinkOperationSchema, listOperationSchema, ]);
- src/modules/data.ts:686-734 (handler)Main handler function for 'manage_location' tool. Parses input using manageLocationSchema, dispatches to specific operation handlers (handleCreate, handleGet, etc.), formats output as ASCII box using createBox, and returns MCP CallToolResult format.export async function manageLocation(input: unknown): Promise<{ content: { type: 'text'; text: string }[] }> { try { const parsed = manageLocationSchema.parse(input); let result: string; switch (parsed.operation) { case 'create': result = handleCreate(parsed); break; case 'get': result = handleGet(parsed); break; case 'update': result = handleUpdate(parsed); break; case 'delete': result = handleDelete(parsed); break; case 'link': result = handleLink(parsed); break; case 'unlink': result = handleUnlink(parsed); break; case 'list': result = handleList(parsed); break; default: result = createBox('ERROR', ['Unknown operation'], DISPLAY_WIDTH); } return { content: [{ type: 'text' as const, text: result }] }; } catch (error) { const lines: string[] = []; if (error instanceof z.ZodError) { for (const issue of error.issues) { lines.push(`${issue.path.join('.')}: ${issue.message}`); } } else if (error instanceof Error) { lines.push(error.message); } else { lines.push('An unknown error occurred'); } return { content: [{ type: 'text' as const, text: createBox('ERROR', lines, DISPLAY_WIDTH) }] }; } }
- src/modules/data.ts:92-95 (helper)In-memory state stores for locations (nodes) and edges (connections) in the location graph, used by all manage_location operations.const locationStore = new Map<string, Location>(); /** In-memory edge storage */ const edgeStore = new Map<string, StoredLocationEdge>();