# mcp-nfse-nacional

This MCP server searches NFSe on the national portal, reads invoice details, and downloads PDFs. It suits agent-driven access to electronic service invoices.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 18
- Author: SamuelMoraesF
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/SamuelMoraesF/mcp-nfse-nacional
- Updated: 2026-02-12
- HTML: https://affpapa.org/en/nevibecode/mcp/mcp-nfse-nacional

## What it does

mcp-nfse-nacional connects an AI agent to the national NFSe portal. It searches issued invoices within a date range and returns each record’s date, recipient, amount, status, and key. A key can then be used to fetch full invoice data, save its XML, or download a DANFSe PDF.

The server exposes three MCP tools: `nfse_buscar`, `nfse_detalhes`, and `nfse_pdf`. Login happens on the first call, with another attempt after an expired session. It runs through `npx` with either `stdio` or `streamable-http`; downloaded files are stored under `./storage` by default.

A digital certificate file in `.pfx` or `.p12` format and its password must be supplied through `CERT_FILE` and `CERT_PASSWORD`. The `streamable-http` mode has no built-in authentication, so exposing it publicly requires an authenticated reverse proxy or equivalent protection.

## Requirements
- Needs: Node.js (commands run via npx)
- Environment variables: `CERT_PASSWORD`, `CERT_FILE`, `NODE_OPTIONS`, `MCP_PORT`, `STORAGE_PATH` — keys and tokens: ask the human for the values, never commit them or put them in shared files.

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add --env CERT_PASSWORD=<CERT_PASSWORD> --env CERT_FILE=<CERT_FILE> --env NODE_OPTIONS=<NODE_OPTIONS> --env MCP_PORT=<MCP_PORT> --env STORAGE_PATH=<STORAGE_PATH> --transport stdio mcp-nfse-nacional -- npx -y mcp-nfse-nacional
```
Replace <…> with your own values

### Codex

**Platform CLI**
```bash
codex mcp add mcp-nfse-nacional --env CERT_PASSWORD=<CERT_PASSWORD> --env CERT_FILE=<CERT_FILE> --env NODE_OPTIONS=<NODE_OPTIONS> --env MCP_PORT=<MCP_PORT> --env STORAGE_PATH=<STORAGE_PATH> -- npx -y mcp-nfse-nacional
```
Replace <…> with your own values

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "mcp-nfse-nacional": {
            "command": "npx",
            "args": [
                "-y",
                "mcp-nfse-nacional"
            ],
            "env": {
                "CERT_PASSWORD": "<CERT_PASSWORD>",
                "CERT_FILE": "<CERT_FILE>",
                "NODE_OPTIONS": "<NODE_OPTIONS>",
                "MCP_PORT": "<MCP_PORT>",
                "STORAGE_PATH": "<STORAGE_PATH>"
            }
        }
    }
}
```
Replace <…> with your own values

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "mcp-nfse-nacional": {
            "type": "stdio",
            "command": "npx",
            "args": [
                "-y",
                "mcp-nfse-nacional"
            ],
            "env": {
                "CERT_PASSWORD": "<CERT_PASSWORD>",
                "CERT_FILE": "<CERT_FILE>",
                "NODE_OPTIONS": "<NODE_OPTIONS>",
                "MCP_PORT": "<MCP_PORT>",
                "STORAGE_PATH": "<STORAGE_PATH>"
            }
        }
    }
}
```
Replace <…> with your own values

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add -e CERT_PASSWORD=<CERT_PASSWORD> -e CERT_FILE=<CERT_FILE> -e NODE_OPTIONS=<NODE_OPTIONS> -e MCP_PORT=<MCP_PORT> -e STORAGE_PATH=<STORAGE_PATH> mcp-nfse-nacional npx -y mcp-nfse-nacional
```
Replace <…> with your own values

## When to use it
- search issued NFSe within a date range
- inspect an invoice using its key
- save NFSe XML to local storage
- download a DANFSe PDF
- let an AI agent query NFSe records

## Example prompts
- Find issued NFSe between `YYYY-MM-DD` and `YYYY-MM-DD`.
- Retrieve the full NFSe record for its key and save the XML locally.
- Download the DANFSe PDF for the NFSe with the given key.

## Similar
- [MCP Toolbox for Databases](https://affpapa.org/en/nevibecode/mcp/googleapis-mcp-toolbox-for-databases.md) — MCP server · ★ 16717
- [PostHog MCP Server](https://affpapa.org/en/nevibecode/mcp/posthog-mcp-server.md) — MCP server · ★ 40409
- [OpenWork MCP Gateway](https://affpapa.org/en/nevibecode/mcp/openwork-mcp-gateway.md) — MCP server · ★ 24242
- [Keploy](https://affpapa.org/en/nevibecode/mcp/keploy.md) — MCP server · ★ 18727
- [Nhost](https://affpapa.org/en/nevibecode/mcp/nhost.md) — MCP server · ★ 9366
- [basebalance.cloud — x402 RPC & MCP gateway](https://affpapa.org/en/nevibecode/mcp/basebalancecloud-x402-rpc-mcp-gateway.md) — MCP server · ★ 7506

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
