|
|
|
@@ -2,58 +2,90 @@ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
|
|
|
|
import type { SceneOperations } from '../operations'
|
|
|
|
|
|
|
|
|
|
export const AGENT_GUIDE = [
|
|
|
|
|
'# Pascal MCP agent guide',
|
|
|
|
|
'# Pascal MCP Agent Guide',
|
|
|
|
|
'',
|
|
|
|
|
'Use this guide before inspecting application source code. The MCP surface is intended to expose the construction contract an agent needs for normal scene editing.',
|
|
|
|
|
'You are editing Pascal architectural projects. Use MCP tools only; do not inspect the Pascal repository unless the user explicitly asks.',
|
|
|
|
|
'',
|
|
|
|
|
'## Fast visible-progress workflow',
|
|
|
|
|
'## Standard Workflow',
|
|
|
|
|
'',
|
|
|
|
|
'1. Query `pascal://scene/current/summary` or `list_levels` to orient yourself.',
|
|
|
|
|
'2. Create visible massing first: `create_level` as needed, then `create_story_shell` once per story.',
|
|
|
|
|
'3. Add room semantics next: zones/rooms, interior walls, slabs, and ceilings. Prefer `create_room` for simple rooms and `apply_patch` only for exact multi-room partitions.',
|
|
|
|
|
'4. Add circulation and envelope details: `create_stair_between_levels`, then `add_door` and `add_window`.',
|
|
|
|
|
'5. Add `create_roof`, furniture with `furnish_room`/`place_item`, and exterior features such as fences, patios, driveways, lawns, and garden zones.',
|
|
|
|
|
'6. Run `validate_scene` and `verify_scene`; fix issues before handing off.',
|
|
|
|
|
'1. Read this guide or call `get_capabilities` if available.',
|
|
|
|
|
'2. If the user asks for a new project, call `create_project` first.',
|
|
|
|
|
'3. For quick starts, call `create_house_from_brief`. For precise edits, build with semantic tools: `create_story_shell`, `create_room`, `add_door`, `add_window`, `furnish_room`, `create_roof`, `place_item`.',
|
|
|
|
|
'4. Let semantic tools update the browser-visible draft. Call `save_scene` with `saveMode: "draft"` for autosave-style progress, or `saveMode: "checkpoint"` only for meaningful milestones.',
|
|
|
|
|
'5. Call `validate_scene`, `verify_scene`, then `get_project_status`.',
|
|
|
|
|
'6. Return the final `editorUrl` from tool output. Do not infer routes.',
|
|
|
|
|
'',
|
|
|
|
|
'This sequence lets users see a recognizable building quickly instead of waiting for one large hidden planning pass.',
|
|
|
|
|
'## Important Concepts',
|
|
|
|
|
'',
|
|
|
|
|
'## Construction rules',
|
|
|
|
|
'- A project is the browser-visible container.',
|
|
|
|
|
'- A scene graph is the architectural model.',
|
|
|
|
|
'- A draft is the browser-visible working model and may be overwritten many times.',
|
|
|
|
|
'- A version/checkpoint is a meaningful saved model revision.',
|
|
|
|
|
'- The browser editor opens the current draft when one exists, otherwise the published version.',
|
|
|
|
|
'- Always return the `editorUrl`, not an internal API URL.',
|
|
|
|
|
'',
|
|
|
|
|
'- Levels live under a Building.',
|
|
|
|
|
'- Walls, fences, zones, slabs, ceilings, roofs, and stairs live under a Level.',
|
|
|
|
|
'- Doors and windows live under their Wall. Use `add_door`/`add_window`; their `t` or `position` is 0..1 along the wall.',
|
|
|
|
|
'- Floor items live under a Level; wall/ceiling-attached items live under their target Wall or Ceiling.',
|
|
|
|
|
'- For multi-story buildings, create separate level-owned exterior walls for each story. Do not make first-story walls taller to represent upper-story bearing walls.',
|
|
|
|
|
'- Use `create_story_shell` once per floor/story to avoid cross-level wall ownership mistakes.',
|
|
|
|
|
'- Use `create_stair_between_levels` for stairs. It creates a straight stair and one rectangular manual slab/ceiling opening while disabling automatic stair-opening mode, avoiding duplicate or irregular holes.',
|
|
|
|
|
'- Roofs are containers with roof segments and should be isolated on a dedicated roof level for solo/exploded level views. Use `create_roof`; by default it creates a roof level above the reference occupied level. Do not attach roofs directly to the top occupied floor unless explicitly requested.',
|
|
|
|
|
'- Story count means occupied stories, not raw level count. A two-story house may correctly have three levels when the third level has metadata role `roof`; do not delete roof/support levels to satisfy a requested story count.',
|
|
|
|
|
'- Use `pascal://constraints/{levelId}` when you need existing slab holes or wall footprints for precise placement.',
|
|
|
|
|
'## URLs',
|
|
|
|
|
'',
|
|
|
|
|
'## Scene model facts exposed here so agents do not need repo inspection',
|
|
|
|
|
'- Use `editorUrl` returned by tools.',
|
|
|
|
|
'- If a tool returns only an id, call `get_project_status` to get the browser URL.',
|
|
|
|
|
'- Hosted editor URLs use `/editor/<projectId>`.',
|
|
|
|
|
'',
|
|
|
|
|
'## Scene Creation Rules',
|
|
|
|
|
'',
|
|
|
|
|
'- Prefer semantic tools over raw graph patches.',
|
|
|
|
|
'- Do not hand-write node graphs unless no semantic tool exists.',
|
|
|
|
|
'- For rooms, use `create_room` -> `add_door` -> `add_window` -> `furnish_room`.',
|
|
|
|
|
'- For complete homes, create exterior shell, interior rooms, openings, roof, furniture, then landscaping.',
|
|
|
|
|
'- For doors/windows, use `t` or `position` from 0 to 1 along the wall unless a tool explicitly says otherwise.',
|
|
|
|
|
'- X/Z are floor-plan axes and Y is vertical; dimensions are meters.',
|
|
|
|
|
'- A story wall height is normally 2.4-3.0m; wall thickness is normally 0.1-0.3m.',
|
|
|
|
|
'- Slab and ceiling holes are polygon arrays. Manual stair openings should have `holeMetadata` with source `manual` and a single rectangular polygon.',
|
|
|
|
|
'- Dedicated roof levels use metadata role `roof` and normally contain the roof only; the top occupied level keeps its own walls, rooms, slabs, and ceiling.',
|
|
|
|
|
'- `verify_scene` reports `occupiedStoryCount`, `supportLevelCount`, and `roofLevelIds`; use those fields instead of `levelCount` when checking story-count requirements.',
|
|
|
|
|
'- Saved site children can contain embedded building objects for compatibility, but tools handle parent/child bookkeeping. Prefer tools over raw graph surgery for common construction.',
|
|
|
|
|
'- `validate_scene` checks schema correctness. `verify_scene` checks practical layout issues such as empty levels, missing rooms/floors/doors, bad openings, stair obstructions, and suspicious multi-story wall heights.',
|
|
|
|
|
'- Use `create_roof` for roofs. A dedicated roof support level is valid and should not count as an occupied story.',
|
|
|
|
|
'',
|
|
|
|
|
'## Tool preference',
|
|
|
|
|
'## Required Final Checks',
|
|
|
|
|
'',
|
|
|
|
|
'- Prefer semantic tools first: `create_story_shell`, `create_room`, `add_door`, `add_window`, `create_stair_between_levels`, `create_roof`, `furnish_room`, `place_item`.',
|
|
|
|
|
'- Use `apply_patch` for bulk exact edits after semantic tools have established the main structure.',
|
|
|
|
|
'- `save_scene` must succeed. Use `saveMode: "checkpoint"` before final handoff only if the user asked for a durable version.',
|
|
|
|
|
'- `verify_scene.hasIssues` should be false; otherwise explain remaining issues.',
|
|
|
|
|
'- `get_project_status.nodeCount` must be greater than 0 for a non-empty design.',
|
|
|
|
|
'- Return `editorUrl` in the final user response.',
|
|
|
|
|
'',
|
|
|
|
|
'## If Something Looks Empty',
|
|
|
|
|
'',
|
|
|
|
|
'1. Call `get_project_status`.',
|
|
|
|
|
'2. Compare `publishedVersion`, `latestVersion`, `browserVisibleVersion`, `nodeCount`, and `graphHash`.',
|
|
|
|
|
'3. If the graph is non-empty but the browser appears empty, call `get_project_status` to re-bind the session, then `save_scene` with `saveMode: "draft"`.',
|
|
|
|
|
'4. Re-run `verify_scene`.',
|
|
|
|
|
'',
|
|
|
|
|
'## Output Contract',
|
|
|
|
|
'',
|
|
|
|
|
'Final user response should include: project name, `editorUrl`, version, node/room summary, and any known limitations.',
|
|
|
|
|
].join('\n')
|
|
|
|
|
|
|
|
|
|
export function registerAgentGuide(server: McpServer, _bridge: SceneOperations): void {
|
|
|
|
|
server.registerResource(
|
|
|
|
|
'agent-guide',
|
|
|
|
|
'pascal://agent-guide',
|
|
|
|
|
{
|
|
|
|
|
title: 'Pascal MCP agent guide',
|
|
|
|
|
description:
|
|
|
|
|
'Short MCP-first project creation, save/publish, validation, and output workflow for external agents.',
|
|
|
|
|
mimeType: 'text/markdown',
|
|
|
|
|
},
|
|
|
|
|
async (uri) => ({
|
|
|
|
|
contents: [
|
|
|
|
|
{
|
|
|
|
|
uri: uri.href,
|
|
|
|
|
mimeType: 'text/markdown',
|
|
|
|
|
text: AGENT_GUIDE,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
server.registerResource(
|
|
|
|
|
'agent-guide-legacy',
|
|
|
|
|
'pascal://agent/guide',
|
|
|
|
|
{
|
|
|
|
|
title: 'Agent construction guide',
|
|
|
|
|
description:
|
|
|
|
|
'MCP-first construction workflow, scene invariants, and tool preferences so agents do not need to inspect the Pascal codebase.',
|
|
|
|
|
title: 'Pascal MCP agent guide',
|
|
|
|
|
description: 'Legacy URI for the Pascal MCP agent guide. Prefer pascal://agent-guide.',
|
|
|
|
|
mimeType: 'text/markdown',
|
|
|
|
|
},
|
|
|
|
|
async (uri) => ({
|
|
|
|
|