mirror of
https://github.com/ArthurDanjou/artapi.git
synced 2026-01-14 20:59:26 +01:00
40 lines
792 B
TypeScript
40 lines
792 B
TypeScript
import { z } from 'zod'
|
|
|
|
export default defineMcpTool({
|
|
description: 'Read a resource from the server API',
|
|
inputSchema: {
|
|
resource: z.enum([
|
|
'contact',
|
|
'education',
|
|
'experiences',
|
|
'hobbies',
|
|
'languages',
|
|
'profile',
|
|
'projects',
|
|
'skills',
|
|
'uses'
|
|
]).describe('resource name')
|
|
},
|
|
handler: async ({ resource }) => {
|
|
try {
|
|
const data = await $fetch(`/api/${resource}`)
|
|
|
|
return {
|
|
content: [{
|
|
type: 'text',
|
|
text: JSON.stringify(data, null, 2)
|
|
}]
|
|
}
|
|
}
|
|
catch (error) {
|
|
return {
|
|
content: [{
|
|
type: 'text',
|
|
text: `Error: ${error instanceof Error ? error.message : String(error)}`
|
|
}],
|
|
isError: true
|
|
}
|
|
}
|
|
}
|
|
})
|