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: sql-mcp

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.

Available Tools

1 tool
listar_clientesListar clientesC

Lista clientes cadastrados no banco PostgreSQL de demonstração.

ParametersJSON Schema
NameRequiredDescriptionDefault
limiteNoQuantidade máxima de clientes retornados.

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It only mentions it lists clients from a demo database but does not disclose any behavioral traits such as performance, side effects, or authentication requirements.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence, concise and front-loaded. There is no extraneous information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple list tool with one parameter and no output schema, the description is minimally adequate. However, it lacks usage guidelines and behavioral transparency, which could be improved.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The single parameter 'limite' is fully described in the schema (quantidade máxima de clientes retornados). The description does not add extra meaning beyond the schema, so baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states the tool lists clients from a PostgreSQL demo database. The verb 'listar' and resource 'clientes' are specific, and there are no sibling tools to differentiate from.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives. No siblings or contextual hints provided, leaving the agent without direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 1 tool updatev1.0.0
    • First observedlistar_clientes

TDQS

C2.9/5.0
Disambiguation5/5

Only one tool exists, so there is no possibility of ambiguity or overlap.

Naming Consistency5/5

With a single tool, naming is trivially consistent.

Tool Count1/5

A single tool is far too few for a client management server; typically such a domain requires multiple CRUD operations.

Completeness1/5

The server only lists clients, missing essential operations like create, update, delete, and get by ID, leaving obvious gaps.

Maintenance

ActivitySlowing
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

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

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    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
    Not graded
    quality
    D
    maintenance
    Enables running parameterized SQL queries against a PostgreSQL database via an MCP tool.
    3
    -
  • A
    license
    Not graded
    quality
    F
    maintenance
    Enables interaction with PostgreSQL databases through MCP, supporting queries, DDL, DML, and schema inspection.
    6
    MIT
  • F
    license
    Not graded
    quality
    C
    maintenance
    Enables querying PostgreSQL databases via MCP, with multi-database routing, credential isolation, and truncated results plus full CSV export.
    -

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