# Connect Gemini CLI to SAM.gov data

To connect Gemini CLI to SAM.gov data, add an mcpServers entry to ~/.gemini/settings.json with httpUrl set to https://samgovapi.io/api/mcp and an Authorization: Bearer header, or run gemini mcp add --transport http. Use httpUrl, not url: url means the older SSE transport, which this server does not offer.

Gemini CLI expands environment variables in settings.json, so the key can stay in your shell. The one setting that trips people up is the field name: httpUrl selects Streamable HTTP; url selects SSE, which opens with a GET this server answers with 405.

- Connects with: MCP
- MCP server: https://samgovapi.io/api/mcp
- REST base: https://samgovapi.io/api/v1
- Auth: Authorization: Bearer <key>, kept in SAMGOVAPI_API_KEY

## Get a key

Free key at https://samgovapi.io/sign-up, or have the agent call start_signup and approve the link it shows you. Reference $SAMGOVAPI_API_KEY in the header value. With double quotes on the command line, your shell writes the key itself into the file.

## Set up Gemini CLI

1. Export your key: Gemini CLI expands $VAR and ${VAR} in string values of settings.json.

Shell:

```bash
export SAMGOVAPI_API_KEY="sg_..."
```

2. Add the server to settings.json: User settings live in ~/.gemini/settings.json; a project can carry its own .gemini/settings.json.

~/.gemini/settings.json:

```json
{
  "mcpServers": {
    "samgovapi": {
      "httpUrl": "https://samgovapi.io/api/mcp",
      "headers": {
        "Authorization": "Bearer $SAMGOVAPI_API_KEY"
      }
    }
  }
}
```

3. Or use the command: Single quotes keep the variable reference in the file instead of the key itself. The default scope is project; -s user makes it global.

Terminal:

```bash
gemini mcp add --transport http -s user \
  --header 'Authorization: Bearer $SAMGOVAPI_API_KEY' \
  samgovapi https://samgovapi.io/api/mcp
```

4. Check it: gemini mcp list shows the server as Connected; /mcp inside a session lists its tools.

Terminal:

```bash
gemini mcp list
```

## Finish account setup once

Data tools unlock after the account answers its onboarding questions: ask the agent to set up your samgovapi account (get_onboarding_questions, then answer_onboarding). Free.

## Check that it works

Ask: "Is UEI ZXBCU6K5KL99 registered in SAM.gov, and when does its registration expire?"

Expected tool call:

```json
{"name":"registration_status","arguments":{"id":"ZXBCU6K5KL99","user_request":"check a registration and its expiry"}}
```

## Things to know

- Google's documentation notes that some account types moved to a successor CLI in June 2026; the settings above are for Gemini CLI.

## Troubleshooting

- The server shows DISCONNECTED: Check the field is httpUrl. With url, Gemini CLI tries SSE and the server answers 405.
- INVALID_API_KEY on every call: The variable was empty when Gemini CLI started. Export it and restart.
- ONBOARDING_REQUIRED: Ask Gemini to answer the samgovapi onboarding questions once; it costs no credits.

## Questions

### Does Gemini CLI need a trust setting for this server?

Tool calls ask for confirmation by default. The trust option in the server entry skips confirmations; leave it off until you know the tools.

## Official documentation

- Gemini CLI: MCP servers: https://geminicli.com/docs/tools/mcp-server/
- Gemini CLI: configuration reference: https://geminicli.com/docs/reference/configuration/

Checked 2026-11-13. All guides: https://samgovapi.io/agents.md

Independent. Not affiliated with, endorsed by or sponsored by GSA, SAM.gov or any U.S. government agency. Registering in SAM.gov is free at sam.gov.
