{"meta":{"title":"Copilot CLI ACP server","intro":"Learn about GitHub Copilot CLI's Agent Client Protocol server.","product":"GitHub Copilot","breadcrumbs":[{"href":"/en/copilot","title":"GitHub Copilot"},{"href":"/en/copilot/reference","title":"Reference"},{"href":"/en/copilot/reference/copilot-cli-reference","title":"Copilot CLI reference"},{"href":"/en/copilot/reference/copilot-cli-reference/acp-server","title":"ACP server"}],"documentType":"article"},"body":"# Copilot CLI ACP server\n\nLearn about GitHub Copilot CLI's Agent Client Protocol server.\n\n> [!NOTE]\n> ACP support in GitHub Copilot CLI is in public preview and subject to change.\n\n## Overview\n\nThe Agent Client Protocol (ACP) is a protocol that standardizes communication between clients (such as code editors and IDEs) and agents (such as Copilot CLI). For more details about this protocol, see the [official introduction](https://agentclientprotocol.com/get-started/introduction).\n\n## Use cases\n\n* **IDE integrations:** Build Copilot support into any editor or development environment.\n* **CI/CD pipelines:** Orchestrate agentic coding tasks in automated workflows.\n* **Custom frontends:** Create specialized interfaces for specific developer workflows.\n* **Multi-agent systems:** Coordinate Copilot with other AI agents using a standard protocol.\n\n## Starting the ACP server\n\nGitHub Copilot CLI can be started as an ACP server using the `--acp` flag. The server supports two modes, `stdio` and `TCP`.\n\n### stdio mode (recommended for IDE integration)\n\nBy default, when providing the `--acp` flag, `stdio` mode will be inferred. The `--stdio` flag can also be provided for disambiguation.\n\n```bash\ncopilot --acp --stdio\n```\n\n### TCP mode\n\nIf the `--port` flag is provided in combination with the `--acp` flag, the server is started in TCP mode.\n\n```bash\ncopilot --acp --port 3000\n```\n\n## Integrating with the ACP server\n\nThere is a growing ecosystem of libraries to programmatically interact with ACP servers. Given GitHub Copilot CLI is correctly installed and authenticated, the following example demonstrates using the [typescript](https://agentclientprotocol.com/libraries/typescript) client to send a single prompt and print the AI response.\n\n```typescript\nimport * as acp from \"@agentclientprotocol/sdk\";\nimport { spawn } from \"node:child_process\";\nimport { Readable, Writable } from \"node:stream\";\n\nasync function main() {\n  const executable = process.env.COPILOT_CLI_PATH ?? \"copilot\";\n\n  // ACP uses standard input/output (stdin/stdout) for transport; we pipe these for the NDJSON stream.\n  const copilotProcess = spawn(executable, [\"--acp\", \"--stdio\"], {\n    stdio: [\"pipe\", \"pipe\", \"inherit\"],\n  });\n\n  if (!copilotProcess.stdin || !copilotProcess.stdout) {\n    throw new Error(\"Failed to start Copilot ACP process with piped stdio.\");\n  }\n\n  // Create ACP streams (NDJSON over stdio)\n  const output = Writable.toWeb(copilotProcess.stdin) as WritableStream<Uint8Array>;\n  const input = Readable.toWeb(copilotProcess.stdout) as ReadableStream<Uint8Array>;\n  const stream = acp.ndJsonStream(output, input);\n\n  const client: acp.Client = {\n    async requestPermission(params) {\n      // This example should not trigger tool calls; if it does, refuse.\n      return { outcome: { outcome: \"cancelled\" } };\n    },\n\n    async sessionUpdate(params) {\n      const update = params.update;\n\n      if (update.sessionUpdate === \"agent_message_chunk\" && update.content.type === \"text\") {\n        process.stdout.write(update.content.text);\n      }\n    },\n  };\n\n  const connection = new acp.ClientSideConnection((_agent) => client, stream);\n\n  await connection.initialize({\n    protocolVersion: acp.PROTOCOL_VERSION,\n    clientCapabilities: {},\n  });\n\n  const sessionResult = await connection.newSession({\n    cwd: process.cwd(),\n    mcpServers: [],\n  });\n\n  process.stdout.write(\"Session started!\\n\");\n  const promptText = \"Hello ACP Server!\";\n  process.stdout.write(`Sending prompt: '${promptText}'\\n`);\n\n  const promptResult = await connection.prompt({\n    sessionId: sessionResult.sessionId,\n    prompt: [{ type: \"text\", text: promptText }],\n  });\n\n  process.stdout.write(\"\\n\");\n\n  if (promptResult.stopReason !== \"end_turn\") {\n    process.stderr.write(`Prompt finished with stopReason=${promptResult.stopReason}\\n`);\n  }\n\n  // Best-effort cleanup\n  copilotProcess.stdin.end();\n  copilotProcess.kill(\"SIGTERM\");\n  await new Promise<void>((resolve) => {\n    copilotProcess.once(\"exit\", () => resolve());\n    setTimeout(() => resolve(), 2000);\n  });\n}\n\nmain().catch((error) => {\n  console.error(error);\n  process.exitCode = 1;\n});\n```\n\n## Further reading\n\n* [Official ACP documentation](https://agentclientprotocol.com/protocol/overview)"}