Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on:
push:
branches: [main]
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

- name: Install uv
uses: astral-sh/setup-uv@v9

- name: Install dependencies
run: uv sync --frozen --all-groups

- name: Ruff lint
run: uv run ruff check --output-format=github server.py

- name: Pyrefly type check
run: uv run pyrefly check

- name: Build package
run: uv build
24 changes: 24 additions & 0 deletions .github/workflows/publish.yml

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aspeddro aspeddro Jul 27, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rdahis esse PR tem alguns ajustes no mcp, principalmente para publicar no pypi. Tem interesse em publicar o mcp?

Se sim você pode configurar o pypi para fazer o lançamento usando github actions automaticamente? https://docs.pypi.org/trusted-publishers/creating-a-project-through-oidc/

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Publish

on:
push:
tags:
- "v*"

jobs:
publish:
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write # required for PyPI trusted publishing (OIDC)
steps:
- uses: actions/checkout@v7

- name: Install uv
uses: astral-sh/setup-uv@v9

- name: Build package
run: uv build

- name: Publish to PyPI
run: uv publish --trusted-publishing always
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
44 changes: 33 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,27 @@ Cada ferramenta de cadastro aceita um parâmetro `env`:

## Instalação

O projeto usa [uv](https://docs.astral.sh/uv/). Instale-o com:

```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
```

### Uso via `uvx` (recomendado)

Não é necessário clonar o repositório. O `uvx` baixa e executa o servidor em um ambiente isolado:

```bash
pip install -r requirements.txt
uvx databasis-mcp
```

### Desenvolvimento a partir do repositório

```bash
git clone https://github.com/basedosdados/mcp.git
cd mcp
uv sync # cria o .venv e instala as dependências
uv run server.py # executa o servidor
```

---
Expand All @@ -180,12 +199,12 @@ pip install -r requirements.txt

As credenciais são lidas automaticamente de `~/.basedosdados/credentials.json` — não é necessário passá-las como variáveis de ambiente.

Substitua `/caminho/para/python` e `/caminho/para/mcp/server.py` pelos caminhos corretos na sua máquina.
Todos os exemplos abaixo usam `uvx`, que resolve e executa o servidor automaticamente.

### Claude Code (CLI)

```bash
claude mcp add databasis -- /caminho/para/python /caminho/para/mcp/server.py
claude mcp add databasis -- uvx databasis-mcp
```

Ou adicione manualmente ao `~/.claude/settings.json`:
Expand All @@ -195,8 +214,8 @@ Ou adicione manualmente ao `~/.claude/settings.json`:
"mcpServers": {
"databasis": {
"type": "stdio",
"command": "/caminho/para/python",
"args": ["/caminho/para/mcp/server.py"]
"command": "uvx",
"args": ["databasis-mcp"]
}
}
}
Expand All @@ -215,8 +234,8 @@ Adicione ao `claude_desktop_config.json`:
{
"mcpServers": {
"databasis": {
"command": "/caminho/para/python",
"args": ["/caminho/para/mcp/server.py"]
"command": "uvx",
"args": ["databasis-mcp"]
}
}
}
Expand All @@ -231,8 +250,8 @@ Adicione ao `.vscode/mcp.json` no seu workspace (ou nas configurações globais
"servers": {
"databasis": {
"type": "stdio",
"command": "/caminho/para/python",
"args": ["/caminho/para/mcp/server.py"]
"command": "uvx",
"args": ["databasis-mcp"]
}
}
}
Expand All @@ -246,11 +265,14 @@ Qualquer cliente compatível com MCP via stdio pode usar o mesmo padrão:
{
"mcpServers": {
"databasis": {
"command": "/caminho/para/python",
"args": ["/caminho/para/mcp/server.py"]
"command": "uvx",
"args": ["databasis-mcp"]
}
}
}
```

Consulte a documentação do seu cliente para o local exato do arquivo de configuração.

> **Rodando a partir de um clone local?** Substitua `"command": "uvx", "args": ["databasis-mcp"]`
> por `"command": "uv", "args": ["run", "--directory", "/caminho/para/mcp", "server.py"]`.
63 changes: 63 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
[project]
name = "databasis-mcp"
version = "0.1.0"
description = "MCP server exposing the Base dos Dados (basedosdados.org) API — metadata search, BigQuery queries, and metadata registration — as tools for AI agents."
readme = "README.md"
requires-python = ">=3.11"
license = { text = "MIT" }
authors = [{ name = "Ricardo Dahis", email = "rdahis@basedosdados.org" }]
keywords = ["mcp", "basedosdados", "bigquery", "llm", "data"]
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
dependencies = [
"fastmcp>=3.4,<4",
"requests>=2.31",
"google-cloud-bigquery>=3.0",
"types-requests>=2.33.0.20260712",
]

[project.urls]
Homepage = "https://basedosdados.org"
Repository = "https://github.com/basedosdados/mcp"

[project.scripts]
databasis-mcp = "server:main"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
only-include = ["server.py"]

[dependency-groups]
dev = [
"pyrefly>=1.1.1",
"ruff>=0.16.0",
]

[tool.ruff]
target-version = "py311"
line-length = 80

[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"F", # pyflakes
"I", # isort
"UP", # pyupgrade
"B", # flake8-bugbear
"SIM", # flake8-simplify
]

ignore = [
# line-to-long
"E501"
]

[tool.pyrefly]
project-includes = ["server.py"]
python-version = "3.11"
3 changes: 0 additions & 3 deletions requirements.txt

This file was deleted.

42 changes: 42 additions & 0 deletions server.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
"name": "io.github.basedosdados/mcp",
"description": "Exposes the Base dos Dados (basedosdados.org) API as tools for AI agents: metadata search, BigQuery queries, and metadata registration.",
"repository": {
"url": "https://github.com/basedosdados/mcp",
"source": "github"
},
"version": "0.1.0",
"packages": [
{
"registryType": "pypi",
"identifier": "databasis-mcp",
"version": "0.1.0",
"runtimeHint": "uvx",
"transport": {
"type": "stdio"
},
"environmentVariables": [
{
"description": "Target backend environment: local, dev, staging, or prod. Defaults to dev.",
"isRequired": false,
"format": "string",
"name": "ENV"
},
{
"description": "GCP project charged for BigQuery queries. Falls back to ~/.basedosdados/credentials.json (gcp_project).",
"isRequired": false,
"format": "string",
"name": "GCP_PROJECT_ID"
},
{
"description": "Base dos Dados backend token (bdtoken_...). Required only for write tools; falls back to ~/.basedosdados/credentials.json.",
"isRequired": false,
"format": "string",
"isSecret": true,
"name": "BACKEND_TOKEN"
}
]
}
]
}
Loading