# Connect LibreChat to SAM.gov data

To connect LibreChat to SAM.gov data, add a samgovapi entry under mcpServers in librechat.yaml with type streamable-http, url https://samgovapi.io/api/mcp, an Authorization header of Bearer ${SAMGOVAPI_API_KEY} and requiresOAuth: false. Restart LibreChat and the tools appear in the MCP settings panel for agents and chats.

LibreChat is the self-hosted chat front end many agencies' contractors run internally. It can share one admin key across users or ask each user for their own, which keeps credits and usage per person.

- 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. For a shared key, set SAMGOVAPI_API_KEY in LibreChat's .env. For per-user keys, users enter them in the UI and LibreChat fills {{SAMGOVAPI_API_KEY}}.

## Set up LibreChat

1. Shared admin key: The key comes from the server's environment. Set requiresOAuth: false: LibreChat's auto-detection probes without your headers and could mistake the 401 for an OAuth server.

librechat.yaml:

```yaml
mcpServers:
  samgovapi:
    type: streamable-http
    url: https://samgovapi.io/api/mcp
    headers:
      Authorization: 'Bearer ${SAMGOVAPI_API_KEY}'
    requiresOAuth: false
```

2. Or a key per user: customUserVars asks each user for their key in the UI.

librechat.yaml:

```yaml
mcpServers:
  samgovapi:
    type: streamable-http
    url: https://samgovapi.io/api/mcp
    requiresOAuth: false
    customUserVars:
      SAMGOVAPI_API_KEY:
        title: 'samgovapi.io API key'
        description: 'Create one at samgovapi.io/dashboard/keys'
        sensitive: true
    headers:
      Authorization: 'Bearer {{SAMGOVAPI_API_KEY}}'
```

3. Restart and check: Restart LibreChat, watch the server log for the MCP connection, and open the MCP settings panel.

## 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

- Servers created in the UI strip ${ENV_VAR} from headers; only customUserVars placeholders survive there.

## Troubleshooting

- LibreChat asks for OAuth: Add requiresOAuth: false to the server entry.
- Header shows the literal ${...}: The variable is not in LibreChat's environment; add it to .env and restart.
- ONBOARDING_REQUIRED: Ask the agent to answer the samgovapi onboarding questions for the account behind the key.

## Questions

### Shared or per-user key?

Per-user keeps usage and credits separate and lets each person revoke their own key. A shared key is simpler for a small team.

## Official documentation

- LibreChat: mcpServers object structure: https://www.librechat.ai/docs/configuration/librechat_yaml/object_structure/mcp_servers

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.
