Metadata-Version: 2.4
Name: nace-mcp
Version: 0.6.0
Summary: MCP server for the Drex API: calibrated decisions and document jobs for coding agents
Keywords: drex,nace,mcp,model-context-protocol,document-intelligence
Author: Nace AI
Author-email: Nace AI <engineering@nace.ai>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Typing :: Typed
Requires-Dist: httpx>=0.27,<1
Requires-Dist: nace-sdk>=0.9.0,<1
Requires-Dist: mcp>=1.28,<2
Requires-Dist: truststore>=0.10.4,<1
Requires-Dist: typing-extensions>=4.12,<5
Requires-Python: >=3.11
Project-URL: Homepage, https://console.nace.ai
Project-URL: Documentation, https://console.nace.ai/docs/developer-tools/mcp
Description-Content-Type: text/markdown

# nace-mcp

A local [MCP](https://modelcontextprotocol.io) server for the Drex API: coding agents get calibrated decisions, document jobs and workspace search as tools. Your agent starts `nace-mcp` on your machine over stdio; it calls Nace's cloud APIs with your API key. MIT; built on [`nace-sdk`](https://pypi.org/project/nace-sdk/). Docs: https://console.nace.ai/docs

For `decide` and `list_models` with one URL and no installation, use Nace's remote MCP server; its docs are at https://console.nace.ai/docs/developer-tools/hosted-mcp

The remote server has a limited free tier without a key; documents, workspaces, search and image inputs are available through this local package.

```bash
nace-mcp login                           # or: uvx nace-mcp login; paste a key from https://console.nace.ai/dashboard/api-keys
claude mcp add nace -- uvx nace-mcp      # Claude Code
```

`nace-mcp login` checks the key against Drex and saves it to `~/.nace/config.toml` (mode 0600), the file `nace login` from [`nace-cli`](https://pypi.org/project/nace-cli/) writes too, so either signs in both. `--api-key KEY` passes the key, `--api-key -` reads it from stdin; without a terminal one of them is required. `$NACE_API_KEY`, `$NACE_BASE_URL` and `$NACE_CONFIG_PATH` in the server's environment override the file. Without a key the server still starts, and every tool answers with how to sign in until one is saved. The server reads the credentials on each call, so `nace-mcp login` while it runs, to sign in or to replace a refused key, needs no restart. `nace-mcp --version` prints the server and SDK versions.

## Connect an agent

Each example passes your API key as `NACE_API_KEY`: replace `nace_sk_...` with a key from https://console.nace.ai/dashboard/api-keys, or leave the key out if you ran `nace-mcp login`.

Claude Code: `claude mcp add nace --env NACE_API_KEY=nace_sk_... -- uvx nace-mcp`.

Codex: `codex mcp add nace --env NACE_API_KEY=nace_sk_... -- uvx nace-mcp` (or a `[mcp_servers.nace]` table with `command = "uvx"`, `args = ["nace-mcp"]` and `env = { NACE_API_KEY = "nace_sk_..." }` in `~/.codex/config.toml`).

OpenCode (`opencode.json`): `"mcp": {"nace": {"type": "local", "command": ["uvx", "nace-mcp"], "environment": {"NACE_API_KEY": "nace_sk_..."}, "enabled": true}}`.

Pi: `pi mcp add nace --env NACE_API_KEY=nace_sk_... -- uvx nace-mcp` (writes `~/.pi/agent/mcp.json`).

Hermes Agent: `hermes mcp add nace --command uvx --env NACE_API_KEY=nace_sk_... --args nace-mcp`, or in `~/.hermes/config.yaml`:

```yaml
mcp_servers:
  nace:
    command: "uvx"
    args: ["nace-mcp"]
    env:
      NACE_API_KEY: "nace_sk_..."
```

Claude Desktop (`claude_desktop_config.json`), Cursor (`~/.cursor/mcp.json`) and Pi (`~/.pi/agent/mcp.json`):

```json
{
  "mcpServers": {
    "nace": {
      "command": "uvx",
      "args": ["nace-mcp"],
      "env": { "NACE_API_KEY": "nace_sk_..." }
    }
  }
}
```

The agent starts the server, so a `NACE_API_KEY` exported in your shell doesn't reach it on its own; Hermes Agent passes a server only the variables under its `env`. To install it once instead of through `uvx`: `uv tool install nace-mcp` or `pipx install nace-mcp` (Python 3.11 or later), then use `nace-mcp` as the command.

## Tools

| Tool | What it does |
| --- | --- |
| `decide` | Answer typed questions (`noul`, `choice`, `score`) about text or JSON, and images with Drex Max, with calibrated probabilities. |
| `list_models` | List the models `decide` can use. |
| `get_balance` | Read what the account can spend now and what running work holds, exact to the nano-dollar. |
| `upload_document` | Upload a local file into a workspace, or to the server without one. |
| `upload_attachment` | Transfer a remote attachment from a trusted HTTPS link or a native file reference. |
| `delete_uploaded_file` | Delete an uploaded file with every version. |
| `parse_document` | Convert a document to Markdown, text or layout blocks. |
| `split_document` | Cut a packet into segments, each with a class. |
| `classify_document` | Label a document, or each page, with your classes. |
| `extract_data` | Fill a JSON Schema, with a status and citation per field. |
| `ground_items` | Find where each quote appears in a document. |
| `get_job` | Read a job and a summary of its result. |
| `wait_for_job` | Wait for a job to finish. |
| `list_jobs` | List jobs, newest first. |
| `cancel_job` | Cancel a running job, or drop a finished one from the list. |
| `get_job_request` | The request a job ran under. |
| `download_job_file` | Save a file a job produced. |
| `get_job_rows` | Page through a parsed sheet's rows. |
| `list_extraction_schemas` | List saved extraction schemas. |
| `get_extraction_schema` | Read a saved schema, at its latest or a given version. |
| `list_extraction_schema_versions` | List a saved schema's versions. |
| `create_extraction_schema` | Save a new extraction schema. |
| `add_extraction_schema_version` | Add a version to a saved schema. |
| `delete_extraction_schema` | Delete a saved schema with every version. |
| `create_workspace` | Create a workspace, optionally against a published `domain_slug` or in a ready `storage_connection_id`. |
| `list_workspaces` | List the account's workspaces. |
| `get_workspace` | Read a workspace and its settings. |
| `workspace_stats` | Summarize what a workspace holds. |
| `use_workspace` | Save a workspace as the default for these tools and the `nace` CLI. |
| `delete_workspace` | Delete a workspace and everything in it. |
| `list_domains` | List the domains a workspace can classify its files against. |
| `get_domain` | Read a domain with its taxonomy. |
| `create_domain` | Create a draft domain of your own. |
| `update_domain` | Rename a draft or replace its taxonomy. |
| `publish_domain` | Freeze a draft so workspaces can use it. |
| `duplicate_domain` | Copy a domain as a draft you can edit. |
| `list_workspace_files` | List a workspace's files. |
| `get_workspace_file` | Read a file, with links to its bytes, its metadata and its versions. |
| `delete_workspace_file` | Delete a file from a workspace. |
| `ingest_workspace` | Make a workspace's files searchable. |
| `automatic_search` | Answer one question from a workspace's files, with cited evidence. |
| `qa` | Ask one turn of a conversation about a workspace's files. |
| `get_documentation` | Usage notes for a topic, shipped with the server. |

The document tools take one source: an `https://` `url`, a local `path` (uploaded first), an uploaded file's `workspace_id` and `file_id`, or a finished parse's `parse_job_id`. Local paths are on the machine running `nace-mcp`; a sandbox path such as `/mnt/data/report.pdf` does not transfer bytes there.

For a remote attachment, call `upload_attachment(download_url=..., file_name=..., workspace_id=...)` with its direct public or signed HTTPS link, then reuse the returned ids. The operator must set `NACE_ATTACHMENT_HOSTS=files.example.com,downloads.example.org` in the server's environment to trust those exact ASCII DNS hostnames. The default is empty, refusing generic downloads. Hostnames must contain at least two labels; no URL syntax, ports, credentials, wildcards, IP addresses or localhost names. Case and surrounding whitespace are normalized; subdomains need their own entry. Invalid configuration refuses all generic downloads. Callers cannot override this policy.

`upload_attachment(file=..., workspace_id=...)` accepts native file references. Pass exactly one of `download_url` or `file`; empty `download_url` and `file_name` strings count as unset. ChatGPT supplies `file` through `openai/fileParams`, with required `download_url` and `file_id`, and optional `file_name` and `mime_type`. This input uses the built-in HTTPS `oaiusercontent.com` and true-subdomain policy independently of that environment variable. A nonempty top-level `file_name` can override the reference's name. Both input forms share a 256 MiB/120-second download limit and private temporary cleanup. The downloader sends no Nace authentication, uses no environment proxy/netrc credentials and follows no redirects. If the file name is absent or unusable, pass `workspace_path` with the original extension. Services requiring extra authentication headers cannot use this contract. The ChatGPT host must forward file references and metadata. The tool needs a `nace-mcp` release whose changelog lists it (refresh a cached `uvx` install).

Document tools wait up to `wait_seconds` (60 at most) and return the job; one still running comes back with an instruction to call `wait_for_job`. Any other request field goes in a tool's `options`; an argument a tool doesn't have is refused rather than ignored. Results are summarised, and text or JSON longer than `max_inline_chars` is written to a file readable only by you, whose path is returned. For a document too large to return inline, `parse_document` saves the full Markdown to a file.

For a remote attachment, call `upload_attachment(download_url=..., file_name=..., workspace_id=...)` with its direct public or signed HTTPS link, then reuse the returned ids. The operator must set `NACE_ATTACHMENT_HOSTS=files.example.com,downloads.example.org` in the server's environment to trust those exact ASCII DNS hostnames. The default is empty, refusing generic downloads. Hostnames must contain at least two labels; no URL syntax, ports, credentials, wildcards, IP addresses or localhost names. Case and surrounding whitespace are normalized; subdomains need their own entry. Invalid configuration refuses all generic downloads. Callers cannot override this policy.

`upload_attachment(file=..., workspace_id=...)` accepts native file references. Pass exactly one of `download_url` or `file`; empty `download_url` and `file_name` strings count as unset. ChatGPT supplies `file` through `openai/fileParams`, with required `download_url` and `file_id`, and optional `file_name` and `mime_type`. This input uses the built-in HTTPS `oaiusercontent.com` and true-subdomain policy independently of that environment variable. A nonempty top-level `file_name` can override the reference's name. Both input forms share a 256 MiB/120-second download limit and private temporary cleanup. The downloader sends no Nace authentication, uses no environment proxy/netrc credentials and follows no redirects. If the file name is absent or unusable, pass `workspace_path` with the original extension. Services requiring extra authentication headers cannot use this contract. The ChatGPT host must forward file references and metadata. The tool needs a `nace-mcp` release whose changelog lists it (refresh a cached `uvx` install).

Document tools wait up to `wait_seconds` (60 at most) and return the job; one still running comes back with an instruction to call `wait_for_job`. Any other request field goes in a tool's `options`; an argument a tool doesn't have is refused rather than ignored. Results are summarised, and text or JSON longer than `max_inline_chars` is written to a file readable only by you, whose path is returned. For a document too large to return inline, `parse_document` saves the full Markdown to a file.

Two ways to search a workspace: `automatic_search` and `qa` hand the question to Drex's search agent, which answers with cited evidence in one call. Or the agent searches it itself with the [`nace` CLI](https://pypi.org/project/nace-cli/)'s `nace locate`, `nace read-file` and `nace run-sql`, to steer the search and check each page, and `nace folder-metadata` and `nace catalog` for questions about the workspace as a whole. The server's instructions tell the agent both, and point it to the `drex-search` skill (`nace skill drex-search` prints it) for the second. The CLI is a package of its own: `uv tool install nace-cli` (or `pipx install nace-cli`), then `nace login`, which saves the key for the CLI and this server alike. `use_workspace` saves the workspace the CLI searches by default. Without `nace` on its `PATH`, the agent is told to ask you to install it and to use `automatic_search` meanwhile.

**CLI availability:** the optional skill-installation and CLI search workflow above needs `nace-cli` 0.5.0 or later. Attachment uploads and the other MCP tools work without the CLI.

A workspace tool without `workspace_id` uses `$NACE_WORKSPACE_ID`, then the workspace `nace workspace-use` saved; with neither it asks for one.

Full documentation: https://console.nace.ai/docs/developer-tools/mcp


## Custom and on-prem servers

Set `NACE_API_KEY` and `NACE_BASE_URL=https://nace.customer.example` in the process using the CLI or MCP server; no login or profile is required. Environment values take precedence over saved configuration. Alternatively, `nace login --base-url https://nace.customer.example --api-key - < key.txt` validates and saves the key and actual server URL for both tools. For unattended profile use, mount a mode-0600 file and set `NACE_CONFIG_PATH` to it.
