Skip to main content
Glama
by wlmwwx

primer

Retrieve real-time contextual data such as location, time, and network details to deliver personalized and localized responses during user interactions.

Instructions

Get up-to-date contextual information of the current session to provide localized, time-aware responses. Use this when you need to know the current time, user's location, or network environment to give more relevant and personalized information.

Input Schema

NameRequiredDescriptionDefault

No arguments

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": {}, "type": "object" }

Implementation Reference

  • Registration of the 'primer' tool using server.tool, including name, description, empty input schema, and inline handler function.
    // Primer tool - provides current world knowledge for LLMs server.tool( "primer", "Get up-to-date contextual information of the current session to provide localized, time-aware responses. Use this when you need to know the current time, user's location, or network environment to give more relevant and personalized information.", {}, async () => { try { const props = getProps(); const context = props.context; if (!context) { throw new Error("No context information available"); } return { content: [{ type: "text" as const, text: yamlStringify(context) }], }; } catch (error) { return createErrorResponse(`Error: ${error instanceof Error ? error.message : String(error)}`); } }, );
  • Handler function that retrieves the session context from props and returns it serialized as YAML text content, with error handling.
    async () => { try { const props = getProps(); const context = props.context; if (!context) { throw new Error("No context information available"); } return { content: [{ type: "text" as const, text: yamlStringify(context) }], }; } catch (error) { return createErrorResponse(`Error: ${error instanceof Error ? error.message : String(error)}`); } },
  • Prepares the context object with timestamp, client headers, geolocation, and network details from Cloudflare request data, which is provided to the primer tool handler.
    // Extract context information for the primer tool const context: any = {}; // Add timestamp info context.timestamp = { utc: new Date().toISOString(), }; if (cf?.timezone) { context.timestamp.userTimezone = cf.timezone; context.timestamp.userLocalTime = new Date().toLocaleString('en-US', { timeZone: cf.timezone as string }); } // Add client info (only if values exist) const client: any = {}; const clientIp = request.headers.get('CF-Connecting-IP'); const userAgent = request.headers.get('User-Agent'); const acceptLanguage = request.headers.get('Accept-Language'); if (clientIp) client.ip = clientIp; if (userAgent) client.userAgent = userAgent; if (acceptLanguage) client.acceptLanguage = acceptLanguage; if (Object.keys(client).length > 0) context.client = client; // Add location info (only if values exist) const location: any = {}; if (cf?.country) location.country = cf.country; if (cf?.city) location.city = cf.city; if (cf?.region) location.region = cf.region; if (cf?.regionCode) location.regionCode = cf.regionCode; if (cf?.continent) location.continent = cf.continent; if (cf?.postalCode) location.postalCode = cf.postalCode; if (cf?.metroCode) location.metroCode = cf.metroCode; if (cf?.timezone) location.timezone = cf.timezone; if (cf?.latitude && cf?.longitude) { location.coordinates = { lat: cf.latitude, lon: cf.longitude }; } if (cf?.isEUCountry === "1") location.isEU = true; if (Object.keys(location).length > 0) context.location = location; // Add network info (only if values exist) const network: any = {}; if (cf?.asn) network.asn = cf.asn; if (cf?.asOrganization) network.organization = cf.asOrganization; if (cf?.colo) network.datacenter = cf.colo; if (cf?.httpProtocol) network.protocol = cf.httpProtocol; if (cf?.tlsVersion) network.tlsVersion = cf.tlsVersion; if (Object.keys(network).length > 0) context.network = network; // Add context to props ctx.props = { ...ctx.props, 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/wlmwwx/jina-mcp'

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