MCPcopy Index your code
hub / github.com/simstudioai/sim / buildUserSkillTool

Function buildUserSkillTool

apps/sim/lib/mothership/skills.ts:24–67  ·  view source on GitHub ↗
(workspaceId: string)

Source from the content-addressed store, hash-verified

22 * into each agent's system prompt on the Go side and never sent as loadable.
23 */
24export async function buildUserSkillTool(workspaceId: string): Promise<ToolSchema | null> {
25 if (!workspaceId) return null
26
27 let rows: { name: string; description: string }[]
28 try {
29 rows = await db
30 .select({ name: skill.name, description: skill.description })
31 .from(skill)
32 .where(eq(skill.workspaceId, workspaceId))
33 } catch (error) {
34 logger.error('Failed to load workspace skills for load_user_skill tool', { error, workspaceId })
35 return null
36 }
37
38 if (rows.length === 0) return null
39
40 const skillNames = rows.map((r) => r.name)
41 const catalog = rows.map((r) => `- ${r.name}: ${r.description}`).join('\n')
42
43 return {
44 name: LOAD_USER_SKILL_TOOL_NAME,
45 description: `Load a user-created skill's full instructions. You MUST call this before following a skill: the list below only tells you which skills exist and when each applies — it is NOT the instructions. To use a skill, call load_user_skill with its exact name and follow the content it returns; never act on a skill's name or description alone. Available skills:\n${catalog}`,
46 input_schema: {
47 type: 'object',
48 properties: {
49 skill_name: {
50 type: 'string',
51 description: 'Exact name of the user skill to load.',
52 enum: skillNames,
53 },
54 },
55 required: ['skill_name'],
56 additionalProperties: false,
57 },
58 // Do NOT set executeLocally: skill content is resolved on the sim backend
59 // (DB), so Go must dispatch this with executor "sim". executeLocally maps to
60 // ClientExecutable, which routes the call to the browser client (no handler)
61 // and the load hangs. mothershipToolKind 'skill' is enough for sim routing.
62 params: {
63 mothershipToolKind: 'skill',
64 mothershipToolName: LOAD_USER_SKILL_TOOL_NAME,
65 },
66 }
67}

Callers 4

skills.test.tsFile · 0.90
executeInboxTaskFunction · 0.90
route.tsFile · 0.90

Calls 3

errorMethod · 0.80
joinMethod · 0.80
eqFunction · 0.50

Tested by

no test coverage detected