create_global_rule
Define and deploy global rules in APISIX-MCP to configure plugins and control plugin behavior across the API gateway.
Instructions
Create a global rule
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | global rule ID | |
| plugins | Yes | plugins configuration |
Implementation Reference
- src/tools/global-rule.ts:6-8 (handler)Registers and implements the handler for the 'create_global_rule' MCP tool. The handler sends a PUT request to the Admin API endpoint `/global_rules/{id}` with the provided arguments to create the global rule.server.tool("create_global_rule", "Create a global rule", CreateGlobalRuleSchema.shape, async (args) => { return await makeAdminAPIRequest(`/global_rules/${args.id}`, "PUT", args); });
- src/schemas/plugin.ts:33-36 (schema)Zod schema defining the input structure for the create_global_rule tool: an object with 'id' (string) and 'plugins' (PluginSchema).export const CreateGlobalRuleSchema = z.object({ id: z.string().describe("global rule ID"), plugins: PluginSchema, });
- src/index.ts:28-28 (registration)Calls the setupGlobalRuleTools function during server initialization, which registers the create_global_rule tool.setupGlobalRuleTools(server);