Skip to content

Commit fd355e8

Browse files
Merge pull request #9 from sveltejs/task-prompt
feat: add Svelte task prompt
2 parents d4edef1 + 26d30c7 commit fd355e8

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/lib/mcp/index.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,46 @@ server.tool(
8989
},
9090
);
9191

92+
server.prompt(
93+
{
94+
name: 'svelte-task-prompt',
95+
title: 'Svelte Task Prompt',
96+
description:
97+
'Use this Prompt to ask for any svelte related task. It will automatically instruct the LLM on how to best use the autofixer and how to query for documentation pages.',
98+
schema: v.object({
99+
task: v.pipe(v.string(), v.description('The task to be performed')),
100+
}),
101+
},
102+
async ({ task }) => {
103+
// TODO: implement logic to fetch the available docs paths to return in the prompt
104+
const available_docs: string[] = [];
105+
106+
return {
107+
messages: [
108+
{
109+
role: 'user',
110+
content: {
111+
type: 'text',
112+
text: `You are a Svelte expert tasked to build components and utilities for Svelte developers. If you need documentation for anything related to Svelte you can invoke the tool \`get_documentation\` with one of the following paths:
113+
<available-docs-paths>
114+
${JSON.stringify(available_docs, null, 2)}
115+
</available-docs-paths>
116+
117+
Every time you write a Svelte component or a Svelte module you MUST invoke the \`svelte-autofixer\` tool providing the code. The tool will return a list of issues or suggestions. If there are any issues or suggestions you MUST fix them and call the tool again with the updated code. You MUST keep doing this until the tool returns no issues or suggestions. Only then you can return the code to the user.
118+
119+
This is the task you will work on:
120+
121+
<task>
122+
${task}
123+
</task>
124+
`,
125+
},
126+
},
127+
],
128+
};
129+
},
130+
);
131+
92132
export const http_transport = new HttpTransport(server, {
93133
cors: true,
94134
});

0 commit comments

Comments
 (0)