Skip to main content
Glama

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
NameRequiredDescriptionDefault
idNostream route id
routeYesstream route configuration

Implementation Reference

  • 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); } });
  • 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, });
  • 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);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/api7/apisix-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server