Get source schema
get_source_schemaRetrieve the inferred schema of a Logflare source, including field names and data types, to understand its structure.
Instructions
Return the inferred schema (field names and types) for a source.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source_token | No | Source token. Falls back to LOGFLARE_DEFAULT_SOURCE_TOKEN if omitted. |
Implementation Reference
- src/index.ts:74-93 (registration)Tool registration for 'get_source_schema' on the MCP server. Defines metadata (title, description) and input schema (optional source_token string), and delegates to client.getSourceSchema().
server.registerTool( 'get_source_schema', { title: 'Get source schema', description: 'Return the inferred schema (field names and types) for a source.', inputSchema: { source_token: z .string() .optional() .describe('Source token. Falls back to LOGFLARE_DEFAULT_SOURCE_TOKEN if omitted.'), }, }, async ({ source_token }) => { try { return text(await client.getSourceSchema(client.resolveSourceToken(source_token))) } catch (err) { return errorText(err) } }, ) - src/logflare.ts:86-88 (handler)Actual handler/implementation of getSourceSchema(). Makes an HTTP GET request to /api/sources/{token}/schema via the generic request() helper.
getSourceSchema(token: string) { return this.request<unknown>(`/api/sources/${encodeURIComponent(token)}/schema`) } - src/logflare.ts:119-127 (helper)resolveSourceToken() helper used by the tool handler; resolves an optional token to a concrete source token, falling back to LOGFLARE_DEFAULT_SOURCE_TOKEN from config.
resolveSourceToken(token: string | undefined): string { const resolved = token || this.cfg.defaultSourceToken if (!resolved) { throw new Error( 'source_token is required (pass it to the tool, or set LOGFLARE_DEFAULT_SOURCE_TOKEN).', ) } return resolved } - src/index.ts:79-84 (schema)Zod input schema for the tool: optional source_token string.
inputSchema: { source_token: z .string() .optional() .describe('Source token. Falls back to LOGFLARE_DEFAULT_SOURCE_TOKEN if omitted.'), },