# Connect VS Code (GitHub Copilot) to SAM.gov data

To connect VS Code's Copilot agent mode to SAM.gov data, add a samgovapi server of type http with url https://samgovapi.io/api/mcp to .vscode/mcp.json, with an Authorization header that reads a password input or ${env:SAMGOVAPI_API_KEY}. Start it from MCP: List Servers and the tools appear in agent mode.

VS Code can prompt for the key once and store it in its secret storage (an input with password: true), which suits shared workspace files. For Copilot setups that forward servers to other harnesses, reading the environment variable is the safer choice, because inputs are not forwarded.

- 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. Prefer the password input for shared workspaces; it never lands in the file. Use the environment variable when the server must run without a prompt.

## Set up VS Code (GitHub Copilot)

1. Add the server with a prompted key: VS Code asks for the value the first time the server starts and stores it securely.

.vscode/mcp.json:

```json
{
  "inputs": [
    {
      "type": "promptString",
      "id": "samgovapi-key",
      "description": "samgovapi.io API key",
      "password": true
    }
  ],
  "servers": {
    "samgovapi": {
      "type": "http",
      "url": "https://samgovapi.io/api/mcp",
      "headers": {
        "Authorization": "Bearer ${input:samgovapi-key}"
      }
    }
  }
}
```

2. Or read the environment: Replace the header value to use a variable instead of a prompt.

.vscode/mcp.json (servers entry):

```json
{
  "servers": {
    "samgovapi": {
      "type": "http",
      "url": "https://samgovapi.io/api/mcp",
      "headers": {
        "Authorization": "Bearer ${env:SAMGOVAPI_API_KEY}"
      }
    }
  }
}
```

3. Or add it from the command line: This writes the server to your user profile.

Terminal:

```bash
code --add-mcp '{"name":"samgovapi","type":"http","url":"https://samgovapi.io/api/mcp","headers":{"Authorization":"Bearer ${env:SAMGOVAPI_API_KEY}"}}'
```

4. Start and check: Run MCP: List Servers, start samgovapi, then open Copilot Chat in agent mode and look for the tools.

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

- A configuration file alone does not prove the connection: start the server and make one tool call.

## Troubleshooting

- The server stays stopped: Run MCP: List Servers, select samgovapi and choose Show Output to see the error.
- VS Code never asked for the key: It asks the first time the server starts. If the stored value is wrong, switch the header to read the environment variable as shown in the second step.
- ONBOARDING_REQUIRED: Ask Copilot to answer the samgovapi onboarding questions once.

## Questions

### Does this work in Copilot ask mode?

MCP tools are used in agent mode.

## Official documentation

- VS Code: MCP servers: https://code.visualstudio.com/docs/copilot/customization/mcp-servers
- VS Code: MCP configuration reference: https://code.visualstudio.com/docs/agents/reference/mcp-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.
