Skip to main content
Glama
processing-postgresql.ts1.55 kB
/** * PostgreSQL Schema Strategy * * Generates database schema documentation for PostgreSQL connections. */ import { ApiConfig } from "@superglue/client"; import { Metadata } from "@superglue/shared"; import { callPostgres } from '../../tools/strategies/postgres/postgres.js'; import { logMessage } from "../../utils/logs.js"; import { composeUrl } from "../../utils/helpers.js"; import { DocumentationProcessingStrategy } from '../types.js'; export class PostgreSqlStrategy implements DocumentationProcessingStrategy { async tryProcess(content: string, config: ApiConfig, metadata: Metadata, credentials?: Record<string, any>): Promise<string | null> { if (config.urlHost?.startsWith("postgres://") || config.urlHost?.startsWith("postgresql://")) { const url = composeUrl(config.urlHost, config.urlPath); const schemaQuery = { query: `SELECT table_name, column_name, data_type, is_nullable, column_default FROM information_schema.columns WHERE table_schema = 'public' ORDER BY table_name, ordinal_position;` }; const schemaResponse = await callPostgres({endpoint: { ...config, body: JSON.stringify(schemaQuery) }, payload: {}, credentials, options: null}); logMessage('info', `PostgreSQL Documentation Fetch: Schema retrieved ${schemaResponse.length} rows`, metadata); if (!schemaResponse) return null; return `${content ? `<DOCUMENTATION>\n${content}\n</DOCUMENTATION>\n` : ""}<DB_SCHEMA>\n${JSON.stringify(schemaResponse, null, 2)}\n</DB_SCHEMA>`; } } }

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/superglue-ai/superglue'

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