Skip to content

Add MCP and LSP servers

Use this page to give every teammate the same MCP servers without hand-editing a JSON file per tool. An MCP server is a program, local or remote, that gives an agent tools (GitHub, a database, a browser). Each harness (the agent tool: GitHub Copilot, Claude Code, Cursor, Codex) reads servers from its own config file. You declare a server once in apm.yml; apm install writes every harness’s file and records what it wrote in apm.lock.yaml.

Terminal window
# From an MCP registry
apm install --mcp io.github.github/github-mcp-server
# A local process: everything after -- is the command
apm install --mcp fetch -- npx -y @modelcontextprotocol/server-fetch
# A remote endpoint
apm install --mcp linear --transport http --url https://mcp.linear.app/mcp

Each command adds an entry to apm.yml and installs it:

apm.yml
dependencies:
mcp: []
mcp:
- name: fetch
registry: false
transport: stdio
command: npx
args:
- -y
- '@modelcontextprotocol/server-fetch'

--transport (stdio, http, sse, streamable-http) is inferred from --url or the command when omitted. Add --env KEY=VALUE for a local process and --header KEY=VALUE for a remote one. Rerunning with a different definition asks before replacing it (in CI it exits 2; pass --force).

A registry name such as io.github.github/github-mcp-server resolves against one MCP registry:

RegistryWho publishes
GitHub MCP Registry, https://api.mcp.github.com (default)Entries selected by GitHub
Official MCP Registry, https://registry.modelcontextprotocol.ioAnyone who verifies a namespace; not reviewed
Your organization’s registryYour organization

APM never switches registries on its own: a miss names the registry it searched. Choose another with --registry URL (recorded on the entry as registry:), MCP_REGISTRY_URL for a shell or CI job, or apm config set mcp-registry-url URL for your machine, in that precedence. apm mcp search QUERY searches the selected registry.

How targets: gates which configs get written

Section titled “How targets: gates which configs get written”

APM writes for the harnesses in your targets: and prints the ones it skipped:

[i] Skipped MCP config for claude, codex (active targets: copilot)
HarnessProject fileUser file (-g)
GitHub Copilot.mcp.json$COPILOT_HOME/mcp-config.json (~/.copilot/)
Claude Code.mcp.json (when .claude/ exists)$CLAUDE_CONFIG_DIR/.claude.json (~/.claude.json)
Cursor.cursor/mcp.json~/.cursor/mcp.json
Codex.codex/config.toml$CODEX_HOME/config.toml (~/.codex/)

Gemini, OpenCode, Kiro, Windsurf and others: see the Targets matrix. Each harness gets its own keys for remote transports; a harness that cannot use a transport (for example SSE on Codex) is skipped with a warning.

Add targets: to an MCP entry to write it only for those harnesses:

apm.yml
mcp:
- name: io.github.github/github-mcp-server
transport: http
targets: [copilot, claude]

APM uses the list to decide where to write the server; it never copies targets: into a harness’s config. An install scoped with --target leaves servers that other targets declared in place.

If opencode.json already has an mcp.servers object, APM writes the OpenCode 2 layout there. Otherwise it writes the OpenCode 1 mcp layout, which OpenCode 2 also reads. To opt in, add "mcp": {"servers": {}} and reinstall. APM never converts entries it did not write.

Write secrets as references, never values:

apm.yml
- name: linear
registry: false
transport: http
url: https://mcp.linear.app/mcp
headers:
Authorization: "Bearer ${LINEAR_TOKEN}"

APM writes each harness’s own reference syntax (Cursor gets ${env:LINEAR_TOKEN}) so the harness reads the value when it starts the server. Static values are written as authored. Registry servers prompt once for required variables. Harness-by-harness support: MCP variable compatibility.

When a remote server is named github-mcp-server, github, github-mcp or github-copilot-mcp-server and its URL host is a GitHub host, APM adds an Authorization header from the earliest variable set among GITHUB_COPILOT_PAT, GITHUB_TOKEN, GITHUB_APM_PAT and GITHUB_PERSONAL_ACCESS_TOKEN. It writes a reference where the harness supports one. An Authorization header in apm.yml wins. Other servers need an explicit --header.

Older releases could write resolved values. Start by replacing any static secret in apm.yml with a ${VAR} reference. For Claude Code’s project .mcp.json, the next apm install replaces the values APM recorded that it wrote; otherwise it exits with an error naming each field. For Cursor and others, edit the value to the harness’s reference syntax by hand, keeping other fields. Rotate any credential that was committed: editing the file does not revoke it.

A plugin APM installs whole to .agents/plugins/ keeps its MCP and LSP servers: Claude Code and Copilot load them from the plugin under your organization’s MCP policy, and APM writes no entry for them in those harnesses; other targets still get APM’s copy (Install plugins).

A server declared by a package you depend on is code that runs on your machine. APM holds back a server from a transitive package when it is self-defined, names its own registry or overrides configuration, and tells you how to admit it. Re-declare it in your apm.yml, or approve the package and commit apm.yml. --trust-transitive-mcp admits it for one run, and apm audit --ci still fails it. A dependency’s devDependencies servers never reach you.

If a harness config already holds a different server under the same name, APM keeps yours, names the target and exits 1. Choose one:

  1. Rename your entry in that harness’s config to keep both.
  2. Or delete your entry, leaving the rest of the file, so APM’s entry replaces it.
  3. Rerun the same command with the same scope and targets.

--force does not take over a connection, and deleting the lockfile does not either.

An LSP server gives an agent code intelligence for a language. Declare it and install the server binary yourself; APM writes the config, not the binary:

apm.yml
dependencies:
lsp:
- name: gopls
command: gopls
args: ["serve"]
extensionToLanguage:
".go": go

APM writes LSP config for Claude Code (.claude/skills/apm-lsp/.claude-plugin/plugin.json, Claude Code 2.1.157 or later; trust the workspace, then run /reload-plugins), Copilot CLI (.github/lsp.json) and OpenCode (opencode.json). Fields: Manifest schema.

The lockfile records which LSP servers APM wrote and to which targets, so apm uninstall removes only those entries and keeps the remaining servers on the targets they were written to, even without targets: in apm.yml.

Terminal window
cat .mcp.json
{
"mcpServers": {
"fetch": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-fetch"
]
}
}
}

Your harness still asks you to trust new project servers; APM does not answer that prompt for you.

Copyright (c) Microsoft Corporation. General documentation: CC-BY-4.0. Software, code examples and OpenAPM: Apache-2.0. See scope and exclusions.