Skip to main content
Glama
leomc06

mcp-opencode

by leomc06

MCP PostgreSQL para OpenCode

Servidor MCP local em Node.js conectado a um PostgreSQL local em Docker e configurado para uso no OpenCode.

Arquitetura

mcp6/
├── src/
│   ├── db.js
│   └── index.js
├── scripts/
│   ├── test-db.js
│   └── test-mcp.js
├── .env.example
├── .gitignore
├── compose.yaml
├── opencode.json
├── package.json
└── README.md

src/db.js carrega o .env e cria o pool de conexão PostgreSQL.

src/index.js cria o servidor MCP via stdio e registra as ferramentas.

compose.yaml sobe o PostgreSQL local na porta 5466.

opencode.json registra o MCP postgres-local no OpenCode.

Related MCP server: Postgres MCP Server

Ferramentas MCP

testar_conexao_postgres: executa SELECT NOW(), current_database(), current_user.

listar_clientes: lista clientes da tabela clientes, com parâmetro opcional limite.

Configuração

Diretório: raiz do projeto.

npm install
cp .env.example .env
chmod 600 .env
docker compose up -d

O .env.example usa estes valores locais:

PGHOST=localhost
PGPORT=5466
PGDATABASE=mcp_demo
PGUSER=mcp_user
PGPASSWORD=mcp_password

Preparar Dados De Teste

Diretório: raiz do projeto.

PGPASSWORD=mcp_password psql -h localhost -p 5466 -U mcp_user -d mcp_demo -c "CREATE TABLE IF NOT EXISTS clientes (id SERIAL PRIMARY KEY, nome TEXT NOT NULL, email TEXT NOT NULL UNIQUE, criado_em TIMESTAMP NOT NULL DEFAULT NOW()); INSERT INTO clientes (nome, email) VALUES ('Ana Silva', 'ana@example.com'), ('Bruno Souza', 'bruno@example.com'), ('Carla Lima', 'carla@example.com') ON CONFLICT (email) DO NOTHING; SELECT id, nome, email, criado_em FROM clientes ORDER BY id;"

Testes

Diretório: raiz do projeto.

npm run test:db
npm run test:mcp
opencode mcp list
npm run inspect

Inspector CLI

Se a CLI do Inspector falhar com erro de cli/package.json, execute os comandos a partir de outro diretório e use caminhos absolutos:

Diretório: /tmp/opencode

/home/leonardo/mcp6/node_modules/.bin/mcp-inspector node /home/leonardo/mcp6/src/index.js --cli --method tools/list
/home/leonardo/mcp6/node_modules/.bin/mcp-inspector node /home/leonardo/mcp6/src/index.js --cli --method tools/call --tool-name listar_clientes --tool-arg limite=3

OpenCode

O OpenCode carrega a configuração do arquivo opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "postgres-local": {
      "type": "local",
      "command": ["node", "src/index.js"],
      "enabled": true
    }
  }
}

Depois de alterar opencode.json, reinicie o OpenCode para a nova configuração ser carregada.

Install Server
F
license - not found
C
quality
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    A
    quality
    C
    maintenance
    Enables secure querying of PostgreSQL databases through MCP-compatible clients. Supports read-only SQL execution, table exploration, and connection management with built-in security validation.
    3
    34
    9
    MIT
  • F
    license
    -
    quality
    C
    maintenance
    Enables querying and modifying PostgreSQL databases through MCP tools with read/write operations, schema inspection, and write-safety constraints that limit modifications to the mcp schema.
    1
  • F
    license
    -
    quality
    C
    maintenance
    Enables running parameterized SQL queries against a PostgreSQL database via an MCP tool.
    3
  • A
    license
    -
    quality
    F
    maintenance
    Enables interaction with PostgreSQL databases through MCP, supporting queries, DDL, DML, and schema inspection.
    6
    MIT

View all related MCP servers

Related MCP Connectors

  • MCP server for managing Prisma Postgres.

  • MCP server for interacting with the Supabase platform

  • Comprehensive PostgreSQL documentation and best practices, including ecosystem tools

View all MCP Connectors

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/leomc06/mcp-opencode'

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