PostgreSQL MCP Database
Explore schemas and run read-only SQL queries on your PostgreSQL databases.
Quick start
- Add a PostgreSQL connection with the settings below, then click Test configuration.
- Create an API key for your agent.
- Paste the key below, click Test endpoint, and copy the configuration for your platform.
| Endpoint | https://market.oshaani.com/postgres (your default connection) or https://market.oshaani.com/postgres/<connection-id> |
|---|---|
| Transport | Streamable HTTP (stateless, JSON responses). MCP protocol versions 2024-11-05 to 2025-11-25 and 2026-07-28. |
| Authentication | Authorization: Bearer <API key>, using a key from the API keys page. |
Agent configuration
initialize and tools/list against the endpoint, exactly like an agent. No credits are charged.
Any MCP client that supports remote (Streamable HTTP) servers with custom headers.
{
"name": "postgres",
"transport": "streamable-http",
"url": "https://market.oshaani.com/postgres",
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
}
}
~/.cursor/mcp.json (all projects) or .cursor/mcp.json in a project.
{
"mcpServers": {
"postgres": {
"url": "https://market.oshaani.com/postgres",
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
}
}
}
}
Settings > Developer > Edit Config (claude_desktop_config.json). Uses the mcp-remote bridge; needs Node.js.
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"https://market.oshaani.com/postgres",
"--header",
"Authorization:${AUTH_HEADER}"
],
"env": {
"AUTH_HEADER": "Bearer YOUR_API_KEY"
}
}
}
}
Run in your terminal, or put the JSON in .mcp.json at the project root.
claude mcp add --transport http postgres https://market.oshaani.com/postgres \
--header "Authorization: Bearer YOUR_API_KEY"
# .mcp.json
{
"mcpServers": {
"postgres": {
"type": "http",
"url": "https://market.oshaani.com/postgres",
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
}
}
}
}
.vscode/mcp.json (GitHub Copilot agent mode). VS Code prompts for the key once and stores it securely.
{
"inputs": [
{
"type": "promptString",
"id": "oshaani-mcp-key",
"description": "oshaani MCP Marketplace API key",
"password": true
}
],
"servers": {
"postgres": {
"type": "http",
"url": "https://market.oshaani.com/postgres",
"headers": {
"Authorization": "Bearer ${input:oshaani-mcp-key}"
}
}
}
}
~/.codeium/windsurf/mcp_config.json
{
"mcpServers": {
"postgres": {
"serverUrl": "https://market.oshaani.com/postgres",
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
}
}
}
}
Responses API remote MCP tool (Python SDK).
from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model="gpt-4.1",
tools=[{
"type": "mcp",
"server_label": "postgres",
"server_url": "https://market.oshaani.com/postgres",
"headers": {"Authorization": "Bearer YOUR_API_KEY"},
"require_approval": "never", # or "always" to approve each tool call
}],
input="What can you do with these tools?",
)
print(response.output_text)
Messages API MCP connector (Python SDK).
import anthropic
client = anthropic.Anthropic()
response = client.beta.messages.create(
model="claude-sonnet-4-5",
max_tokens=1024,
messages=[{"role": "user", "content": "What can you do with these tools?"}],
mcp_servers=[{
"type": "url",
"url": "https://market.oshaani.com/postgres",
"name": "postgres",
"authorization_token": "YOUR_API_KEY",
}],
betas=["mcp-client-2025-04-04"],
)
print(response.content)
Official MCP Python SDK 2.x (pip install mcp); works inside any agent framework.
import asyncio
from mcp import ClientSession
from mcp.client.streamable_http import create_mcp_http_client, streamable_http_client
async def main():
headers = {"Authorization": "Bearer YOUR_API_KEY"}
async with create_mcp_http_client(headers=headers) as http:
async with streamable_http_client("https://market.oshaani.com/postgres", http_client=http) as (read, write, *_):
async with ClientSession(read, write) as session:
await session.initialize()
tools = await session.list_tools()
print([tool.name for tool in tools.tools])
asyncio.run(main())
Quick check from a terminal: lists the tools without charging credits.
curl -s https://market.oshaani.com/postgres \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "MCP-Protocol-Version: 2025-06-18" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
Connection settings
Entered once per connection on market.oshaani.com. Secrets are encrypted and never shown again or sent to agents.
| Setting | Type | Description |
|---|---|---|
Hosthost
required |
string | Public hostname or IP address of the server pattern ^[A-Za-z0-9.:-]+$ |
Portport
|
integer default 5432 |
min 1, max 65535 |
Databasedatabase
required |
string | min length 1, max length 63 |
Usernameusername
required |
string | Use a role that only has SELECT privileges min length 1 |
Passwordpassword
required secret |
string | |
TLS modesslmode
|
"require" | "verify-full" | "prefer" | "disable" default "require" |
verify-full also checks the server certificate against public CAs |
Maximum rows per querymax_rows
|
integer default 500 |
min 1, max 10000 |
Query timeout (seconds)statement_timeout_seconds
|
integer default 15 |
min 1, max 25 |
Tools (5)
list_schemas
read-only
List schemas in the database
No arguments.
list_tables
read-only
List tables and views in a schema with estimated row counts and sizes
| Argument | Type | Description |
|---|---|---|
schema_name |
string default "public" |
min length 1, max length 63 |
describe_table
read-only
Describe a table: columns, types, defaults, primary key, indexes and foreign keys
| Argument | Type | Description |
|---|---|---|
table required |
string | min length 1, max length 63 |
schema_name |
string default "public" |
min length 1, max length 63 |
run_read_query
read-only
Run a read-only SQL query and return the columns and rows
| Argument | Type | Description |
|---|---|---|
sql required |
string | A single SELECT (or WITH ... SELECT) statement min length 1, max length 50000 |
max_rows |
integer | Defaults to the connection's limit min 1, max 10000 |
explain_query
read-only
Show the query plan PostgreSQL would use, without running the query
| Argument | Type | Description |
|---|---|---|
sql required |
string | A single SELECT (or WITH ... SELECT) statement min length 1, max length 50000 |
Billing & errors
Each successful tool call costs 1 oshaani.com credit. initialize, tools/list, failed calls and timeouts are free.
| JSON-RPC code | Meaning |
|---|---|
-32054 (HTTP 401) | Missing, unknown or revoked API key |
-32053 (HTTP 404) | No PostgreSQL connection configured for your organisation, or the connection ID is wrong |
-32055 (HTTP 403) | Connection disabled or origin not allowed |
-32052 (HTTP 429) | Rate limit reached; retry after a minute |
-32050 | Not enough oshaani.com credits for the call |
-32051 | Billing temporarily unavailable; the call was not run |
Errors from PostgreSQL itself (bad IDs, permissions) come back as tool results with isError: true so the agent can read and correct them.
See the PostgreSQL API documentation.