campertunity-mcp-server
Version:
MCP Server for Campertunity - A Model Context Protocol server for interacting with camping and outdoor recreation data
27 lines (26 loc) • 893 B
JavaScript
import { z } from 'zod';
// NOTE: This is a tool since tools are more supported by the MCP protocol
export const placeDetailsTool = (server, campertunityClient) => {
server.tool('place-details', {
placeId: z.string().describe('The id of the place to get details for.'),
}, async ({ placeId }) => {
try {
const place = await campertunityClient.get(`/place/details?placeId=${placeId}`);
return {
content: [
{
type: 'text',
text: JSON.stringify(place),
mimeType: 'application/json',
},
],
};
}
catch (error) {
return {
content: [{ type: 'text', text: 'Error: ' + error.message }],
isError: true,
};
}
});
};