Set up targets
Learn how to use the Agent Gateway UI, a configuration file, or the Agent Gateway admin API to create and delete targets.
Create targets
You can create targets by using the Agent Gateway UI, a configuration file, or the Agent Gateway admin API.
-
Start your Agent Gateway.
agentgateway
-
Open the Agent Gateway listener UI. You must create a listener before you can create a target.
-
Add a listener.
-
From the listener UI, click Add Listener.
-
Enter a Name for your listener, select a protocol, and configure the Address and Port that you want your listener to be exposed on. To use an address that is compatible with IPv4 and IPv6, enter
[::]
. -
Click Add Listener to save your configuration.
-
-
Open the Agent Gateway target UI.
-
Click Add Target and choose your Target Type, such as
MCP
.
MCP
target type.

- Confgure your MCP target.
-
Select the listener you want to attach to the target.
-
Enter a Target Name. The name is used as a prefix for all the MCP tools that are exposed on the MCP server.
-
Select the standard input/output (>_ stdio) tab that allows you to specify a command and command arguments to run your MCP server. In this example, you use the
npx
command utility to run the@modelcontextprotocol/server-everything
server. If your server is exposed on a public URL, you can enter that URL in the SSE tab instead. -
Click Add Target to save your configuration.
-
-
Create a JSON file that contains your listener configuration. The following example sets up these components:
- Listener: An SSE listener that listens for incoming traffic on port 3000.
- Target: The Agent Gateway targets a sample, open source MCP test server,
server-everything
. The server runs the entire MCP stack in a single process and can be used to test, develop, or demo MCP environments. To run the server, you use the standard input/output (stdio
) capability of the Agent Gateway that allows you specify a command and command arguments that you want to run. In this example, you use thenpx
command utility to run the@modelcontextprotocol/server-everything
server.
cat <<EOF > config.json { "type": "static", "listeners": [ { "name": "sse", "protocol": "MCP", "sse": { "address": "[::]", "port": 3000 } } ], "targets": { "mcp": [ { "name": "everything", "stdio": { "cmd": "npx", "args": [ "@modelcontextprotocol/server-everything" ] } } ] } } EOF
-
Run the Agent Gateway.
agentgateway -f config.json
-
Open the Agent Gateway target UI and verify that your target is added successfully.
-
Start your Agent Gateway. The Agent Gateway automatically exposes its admin API on port 19000.
agentgateway
-
Create an SSE listener by using the
/listeners
endpoint. In the following example, the listener is exposed on port 3000. A listener must be created before you can add a target.curl -X POST -H content-type:application/json http://localhost:19000/listeners -d '{"name": "sse", "sse": {"address": "[::]", "port": 3000}}'
-
Verify that the listener is created.
curl http://localhost:19000/listeners
-
Create an MCP target by using the
/targets/mcp
endpoint. In this example, you create theeverything
target that connects to a sample MCP test server,server-everything
. To run the server, you use thenpx
command, which allows you to run a Node.js package without installing it.curl -X POST -H content-type:application/json http://localhost:19000/targets/mcp -d '{"name": "everything", "stdio": {"cmd": "npx", "args": ["@modelcontextprotocol/server-everything"]}}'
-
Verify that the MCP target is created.
curl http://localhost:19000/targets/mcp
Delete targets
Remove Agent Gateway targets with the UI.
-
Run the Agent Gateway from which you want to remove a listener.
agentgateway -f config.json
-
Open the Agent Gateway targets UI and find the target that you want to remove.
-
Click the trash icon to remove the target and confirm the deletion.
Update the configuration file to remove the target.
-
Remove the target from your configuration file.
-
Apply the updated configuration file to your Agent Gateway.
agentgateway -f config.json
Use the Agent Gateway admin API to delete targets from your Agent Gateway.
-
Run the Agent Gateway from which you want to remove a target.
agentgateway -f config.json
-
List all the MCP targets that are configured on your Agent Gateway and note the name of the target that you want to remove. In the following example, the name of the MCP target is
everything
.curl http://localhost:19000/targets/mcp
Example output:
[{"name":"everything","spec":{"Stdio":{"cmd":"npx","args":["@modelcontextprotocol/server-everything"]}}}]
-
Remove the MCP target from your Agent Gateway.
curl -X DELETE http://localhost:19000/targets/mcp/everything
-
Verify that the MCP target is removed.
curl http://localhost:19000/targets/mcp
Example output:
[]
-
List all the A2A targets that are configured on your Agent Gateway and note the name of the target that you want to remove. In the following example, the name of the A2A target is
google_adk
.curl http://localhost:19000/targets/a2a
Example output:
[{"name":"google-adk","host":"127.0.0.1","port":10002}]%
-
Remove the A2A target from your Agent Gateway.
curl -X DELETE curl http://localhost:19000/targets/a2a/google_adk
-
Verify that the A2A target is removed.
curl http://localhost:19000/targets/a2a
Example output:
[]