Skip to content

Commit f1ee9cc

Browse files
committed
Auto-discover setup resource
1 parent 892b90c commit f1ee9cc

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/lib/agent-interface.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ export async function runAgent(
398398
// - File operations: Read, Write, Edit
399399
// - Search: Glob, Grep
400400
// - Commands: Bash (with restrictions via canUseTool)
401+
// - MCP discovery: ListMcpResourcesTool (to find available skills)
401402
// - Skills: Skill (to load installed PostHog skills)
402403
// MCP tools (PostHog) come from mcpServers, not allowedTools
403404
const allowedTools = [
@@ -407,6 +408,7 @@ export async function runAgent(
407408
'Glob',
408409
'Grep',
409410
'Bash',
411+
'ListMcpResourcesTool',
410412
'Skill',
411413
];
412414

src/lib/agent-runner.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,6 @@ function buildIntegrationPrompt(
271271
? '\n' + additionalLines.map((line) => `- ${line}`).join('\n')
272272
: '';
273273

274-
const skillId = config.prompts.getSkillId(frameworkContext);
275-
276274
return `You have access to the PostHog MCP server which provides skills to integrate PostHog into this ${
277275
config.metadata.name
278276
} project.
@@ -285,22 +283,24 @@ Project context:
285283
286284
Instructions (follow these steps IN ORDER - do not skip or reorder):
287285
288-
STEP 1: Fetch the skill resource from: posthog://skills/${skillId}
289-
The resource returns a shell command to install the skill.
290-
If the skill is not accessible, emit: ${
286+
STEP 1: List available skills from the PostHog MCP server using ListMcpResourcesTool.
287+
Review the skill descriptions and choose the one that best matches this project's framework and configuration.
288+
If no suitable skill is found, emit: ${
291289
AgentSignals.ERROR_RESOURCE_MISSING
292-
} Could not access the setup resource.
290+
} Could not find a suitable skill for this project.
291+
292+
STEP 2: Fetch the chosen skill resource (e.g., posthog://skills/{skill-id}).
293+
The resource returns a shell command to install the skill.
293294
294-
STEP 2: Run the installation command using Bash:
295+
STEP 3: Run the installation command using Bash:
295296
- Execute the EXACT command returned by the resource (do not modify it)
296-
- This will download and extract the skill to .claude/skills/${skillId}/
297-
- DO NOT do anything else before running this command - no searches, no Glob, no exploring
297+
- This will download and extract the skill to .claude/skills/{skill-id}/
298298
299-
STEP 3: Load the skill from .claude/skills/${skillId}/SKILL.md
299+
STEP 4: Load the installed skill's SKILL.md file.
300300
301-
STEP 4: Carefully follow the skill's entire PostHog setup procedures to the letter
301+
STEP 5: Carefully follow the skill's entire PostHog setup procedures to the letter.
302302
303-
STEP 5: Set up environment variables for PostHog in a .env file with the API key and host provided above, using the appropriate naming convention for ${
303+
STEP 6: Set up environment variables for PostHog in a .env file with the API key and host provided above, using the appropriate naming convention for ${
304304
config.metadata.name
305305
}. Make sure to use these environment variables in the code files you create instead of hardcoding the API key and host.
306306

0 commit comments

Comments
 (0)