create_or_update_stream_route
Create or update a stream route in APISIX-MCP by defining configuration details such as server address, port, upstream, and plugins. Automatically handles existing routes.
Instructions
Create a stream route, if the stream route already exists, it will be updated
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | stream route id | |
| route | Yes | stream route configuration |
Implementation Reference
- src/tools/stream-route.ts:6-14 (handler)Inline handler function for the 'create_or_update_stream_route' tool. Determines whether to update (PUT) or create (POST) a stream route based on the presence of an 'id' in the arguments, delegating the HTTP request to makeAdminAPIRequest.server.tool("create_or_update_stream_route", "Create a stream route, if the stream route already exists, it will be updated", CreateOrUpdateStreamRouteSchema.shape, async (args) => { const routeId = args.id; if (routeId) { return await makeAdminAPIRequest(`/stream_routes/${routeId}`, "PUT", args.route); } else { return await makeAdminAPIRequest(`/stream_routes`, "POST", args.route); } });
- src/schemas/stream-route.ts:52-55 (schema)Zod schema defining the input structure for the tool: optional 'id' for updates and 'route' configuration object based on StreamRouteSchema.export const CreateOrUpdateStreamRouteSchema = z.object({ id: z.string().optional().describe('stream route id'), route: StreamRouteSchema, });
- src/tools/stream-route.ts:6-14 (registration)Direct registration of the tool using McpServer.tool method, specifying name, description, input schema, and handler.server.tool("create_or_update_stream_route", "Create a stream route, if the stream route already exists, it will be updated", CreateOrUpdateStreamRouteSchema.shape, async (args) => { const routeId = args.id; if (routeId) { return await makeAdminAPIRequest(`/stream_routes/${routeId}`, "PUT", args.route); } else { return await makeAdminAPIRequest(`/stream_routes`, "POST", args.route); } });
- src/index.ts:31-31 (registration)Top-level invocation of the setup function that registers the stream route tools, including 'create_or_update_stream_route'.setupStreamRouteTools(server);