Skip to content

Commit 6d4f9ff

Browse files
committed
feat(bin): add update_vuetify_bin tool
Allows updating existing bins via MCP.
1 parent feef07b commit 6d4f9ff

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

src/tools/one/bin.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,63 @@ export async function registerBinTools (server: McpServer) {
143143
}
144144
})
145145

146+
server.tool(
147+
'update_vuetify_bin',
148+
'Update an existing Vuetify bin. Requires VUETIFY_API_KEY.',
149+
{
150+
id: z.string().describe('The bin ID to update'),
151+
title: z.string().describe('Title of your bin'),
152+
language: z.string().describe('Language of your vuetify bin'),
153+
content: z.string().describe('The content of your bin'),
154+
visibility: z.enum(['private', 'public']).describe('Visibility of bin'),
155+
favorite: z.boolean().default(false),
156+
pinned: z.boolean().default(false),
157+
locked: z.boolean().default(false),
158+
},
159+
{
160+
openWorldHint: true,
161+
},
162+
async ({ id, ...bin }, extra) => {
163+
try {
164+
const apiKey = getApiKey(extra)
165+
const apiServer = process.env.VUETIFY_API_SERVER || 'https://api.vuetifyjs.com'
166+
const binResponse = await fetch(`${apiServer}/one/bins/${id}`, {
167+
method: 'POST',
168+
body: JSON.stringify({
169+
bin: {
170+
...bin,
171+
liveShare: false,
172+
},
173+
}),
174+
headers: {
175+
'Content-Type': 'application/json',
176+
'Authorization': `Bearer ${apiKey}`,
177+
},
178+
})
179+
if (!binResponse.ok) {
180+
throw new Error(await binResponse.text())
181+
}
182+
183+
const data = await binResponse.json()
184+
const updatedBin: Bin = data.bin
185+
186+
return {
187+
content: [{
188+
type: 'text',
189+
text: `Successfully updated bin ${updatedBin.title}, you can view it at https://bin.vuetifyjs.com/bins/${updatedBin.id}`,
190+
}],
191+
}
192+
} catch (error: any) {
193+
return {
194+
isError: true,
195+
content: [{
196+
type: 'text',
197+
text: error.message,
198+
}],
199+
}
200+
}
201+
})
202+
146203
server.tool(
147204
'get_bin',
148205
'Get a bin by ID. Requires VUETIFY_API_KEY.',

0 commit comments

Comments
 (0)