PostgREST

Official
Apache 2.0
372
1,198
  • Apple

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Integrations

  • Enables LLMs to perform database queries and operations on Supabase projects via PostgREST API

  • Offers TypeScript SDK support through the MCP SDK for programmatic integration with PostgREST servers

@supabase/mcp-server-postgrest

PostgREST 용 MCP 서버입니다. LLM이 REST API를 통해 앱에서 CRUD 작업을 수행할 수 있도록 지원합니다.

이 서버는 Supabase 프로젝트(PostgREST를 실행) 및 모든 독립형 PostgREST 서버와 함께 작동합니다.

도구

다음과 같은 도구를 사용할 수 있습니다.

postgrestRequest

구성된 PostgREST 서버에 HTTP 요청을 수행합니다. 다음 인수를 받습니다.

  • method : 사용할 HTTP 메서드(예: GET , POST , PATCH , DELETE )
  • path : 쿼리할 경로(예: /todos?id=eq.1 )
  • body : 요청 본문( POSTPATCH 요청의 경우)

GET 요청에 대한 선택된 행과 POSTPATCH 요청에 대한 업데이트된 행을 포함하여 PostgREST 서버에서 JSON 응답을 반환합니다.

sqlToRest

SQL 쿼리를 동등한 PostgREST 구문(메서드 및 경로)으로 변환합니다. LLM이 유효한 PostgREST 구문으로 변환하기 어려운 복잡한 쿼리에 유용합니다.

PostgREST는 SQL의 일부만 지원하므로 모든 쿼리가 REST로 변환되는 것은 아닙니다. 자세한 내용은 sql-to-rest 참조하세요.

다음 인수를 허용합니다.

  • sql : 변환할 SQL 쿼리입니다.

요청에 대한 methodpath 속성을 포함하는 객체를 반환합니다. LLM은 postgrestRequest 도구를 사용하여 요청을 실행할 수 있습니다.

용법

클로드 데스크톱과 함께

Claude Desktop은 모델 컨텍스트 프로토콜(Model Context Protocol)을 지원하는 인기 LLM 클라이언트입니다. PostgREST 서버를 Claude Desktop에 연결하여 자연어 명령을 통해 데이터베이스에 쿼리를 실행할 수 있습니다.

다음 위치의 구성 파일을 통해 Claude Desktop에 MCP 서버를 추가할 수 있습니다.

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Claude Desktop에 Supabase 프로젝트 (또는 PostgREST 서버) 를 추가하려면 다음 구성을 config 파일의 mcpServers 개체에 추가하세요.

지엑스피1

구성

  • apiUrl : PostgREST 엔드포인트의 기본 URL
  • apiKey : 인증을 위한 API 키 (선택 사항)
  • schema : API를 제공할 Postgres 스키마(예: public ). 비공개 스키마는 PostgREST에서 수동으로 노출해야 합니다.

프로그래밍 방식으로(맞춤형 MCP 클라이언트)

자체 MCP 클라이언트를 구축하는 경우, 원하는 전송 방식을 사용하여 PostgREST 서버에 프로그래밍 방식으로 연결할 수 있습니다. MCP SDK는 stdioSSE 전송 방식을 기본 제공합니다. 또한, 메모리 내에서 MCP 서버에 직접 연결하거나 자체 스트림 기반 전송 방식을 파이핑하여 연결하려는 경우 StreamTransport 제공합니다.

설치

npm i @supabase/mcp-server-postgrest
yarn add @supabase/mcp-server-postgrest
pnpm add @supabase/mcp-server-postgrest

다음 예제에서는 StreamTransport 사용하여 MCP 클라이언트와 서버 간에 직접 연결합니다.

import { Client } from '@modelcontextprotocol/sdk/client/index.js'; import { StreamTransport } from '@supabase/mcp-utils'; import { createPostgrestMcpServer } from '@supabase/mcp-server-postgrest'; // Create a stream transport for both client and server const clientTransport = new StreamTransport(); const serverTransport = new StreamTransport(); // Connect the streams together clientTransport.readable.pipeTo(serverTransport.writable); serverTransport.readable.pipeTo(clientTransport.writable); const client = new Client( { name: 'MyClient', version: '0.1.0', }, { capabilities: {}, } ); const supabaseUrl = 'https://your-project-ref.supabase.co'; // http://127.0.0.1:54321 for local const apiKey = 'your-anon-key'; // or service role, or user JWT const schema = 'public'; // or any other exposed schema const server = createPostgrestMcpServer({ apiUrl: `${supabaseUrl}/rest/v1`, apiKey, schema, }); // Connect the client and server to their respective transports await server.connect(serverTransport); await client.connect(clientTransport); // Call tools, etc const output = await client.callTool({ name: 'postgrestRequest', arguments: { method: 'GET', path: '/todos', }, });
-
security - not tested
A
license - permissive license
-
quality - not tested

PostgREST용 MCP 서버입니다. LLM이 PostgREST를 통해 Postgres 데이터베이스에서 데이터베이스 쿼리 및 작업을 수행할 수 있도록 지원합니다. 이 서버는 PostgREST를 사용하는 Supabase 프로젝트와 독립형 PostgREST 서버 모두에서 작동합니다.

  1. Tools
    1. postgrestRequest
    2. sqlToRest
  2. Usage
    1. With Claude Desktop
    2. Programmatically (custom MCP client)
ID: b4wipgdgar