Skip to main content
Glama
getInitialContextTool.ts1.34 kB
import { z } from 'zod'; import { outdent } from 'outdent'; import { contextStore } from './store.js'; import { withErrorHandling } from '../../utils/response.js'; import { MCP_INSTRUCTIONS } from './instructions.js'; import type { ContentfulConfig } from '../../config/types.js'; export const GetInitialContextToolParams = z.object({}); type Params = z.infer<typeof GetInitialContextToolParams>; export function hasInitialContext(): boolean { return contextStore.hasInitialContext(); } export function getInitialContextTool(config: ContentfulConfig) { async function tool(_params: Params) { const configInfo = `Current Contentful Configuration: - Space ID: ${config.spaceId || 'Not set'} - Environment ID: ${config.environmentId || 'master'} - Organization ID: ${config.organizationId || 'Not set'}`; const todaysDate = new Date().toLocaleDateString('en-US'); const message = outdent` ${MCP_INSTRUCTIONS} This is the initial context for your Contentful instance: <context> ${configInfo} </content> <todaysDate>${todaysDate}</todaysDate> `; contextStore.setInitialContextLoaded(); return { content: [ { type: 'text' as const, text: message, }, ], }; } return withErrorHandling(tool, 'Error getting initial context'); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/contentful/contentful-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server