list_guardrails
List guardrails in your organization with filters by workspace or organization. Use to retrieve IDs and slugs for managing guardrails.
Instructions
List guardrails in the org with id, slug, status, ownership, and optional workspace/org filters. Use this to find IDs and slugs before get_guardrail, update_guardrail, or delete_guardrail.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workspace_id | No | Filter guardrails by workspace ID | |
| organisation_id | No | Filter guardrails by organization ID | |
| page_size | No | Number of items per page (1-1000, default: 100) | |
| current_page | No | Page number for pagination |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | Whether the tool call succeeded and returned structured data | |
| data | No | Structured success payload when ok is true | |
| error | No | Structured error payload when ok is false |
Implementation Reference
- src/tools/guardrails.tools.ts:114-152 (handler)The handler tool registration for 'list_guardrails'. Calls service.guardrails.listGuardrails(params) and maps the response to include id, name, slug, status, workspace_id, organisation_id, created_at, last_updated_at, owner_id, updated_by.
export function registerGuardrailsTools( server: McpServer, service: PortkeyService, ): void { // List guardrails tool server.tool( "list_guardrails", "List guardrails in the org with id, slug, status, ownership, and optional workspace/org filters. Use this to find IDs and slugs before get_guardrail, update_guardrail, or delete_guardrail.", GUARDRAILS_TOOL_SCHEMAS.listGuardrails, async (params) => { const result = await service.guardrails.listGuardrails(params); return { content: [ { type: "text", text: JSON.stringify( { total: result.total, guardrails: result.data.map((guardrail) => ({ id: guardrail.id, name: guardrail.name, slug: guardrail.slug, status: guardrail.status, workspace_id: guardrail.workspace_id, organisation_id: guardrail.organisation_id, created_at: guardrail.created_at, last_updated_at: guardrail.last_updated_at, owner_id: guardrail.owner_id, updated_by: guardrail.updated_by, })), }, null, 2, ), }, ], }; }, ); - src/tools/guardrails.tools.ts:52-112 (schema)Input schema for the listGuardrails tool: optional workspace_id, organisation_id, page_size (1-1000), and current_page.
const GUARDRAILS_TOOL_SCHEMAS = { listGuardrails: { workspace_id: z .string() .optional() .describe("Filter guardrails by workspace ID"), organisation_id: z .string() .optional() .describe("Filter guardrails by organization ID"), page_size: z.coerce .number() .min(1) .max(1000) .optional() .describe("Number of items per page (1-1000, default: 100)"), current_page: z.coerce .number() .positive() .optional() .describe("Page number for pagination"), }, getGuardrail: { guardrail_id: z .string() .describe("The guardrail UUID or slug (with guard_ prefix) to retrieve"), }, createGuardrail: { name: z.string().describe("Name of the guardrail"), checks: z .array(guardrailCheckSchema) .min(1) .describe("Array of checks to apply (at least one required)"), actions: guardrailActionSchema.describe( "Actions to take when guardrail checks pass or fail", ), workspace_id: z .string() .optional() .describe("Workspace ID to create the guardrail in"), organisation_id: z .string() .optional() .describe("Organisation ID (required if workspace_id not provided)"), }, updateGuardrail: { guardrail_id: z.string().describe("The guardrail UUID or slug to update"), name: z.string().optional().describe("New name for the guardrail"), checks: z .array(guardrailCheckSchema) .min(1) .optional() .describe("Updated array of checks to apply"), actions: guardrailActionSchema .optional() .describe("Updated actions configuration"), }, deleteGuardrail: { guardrail_id: z.string().describe("The guardrail UUID or slug to delete"), }, } as const; - TypeScript interfaces ListGuardrailsParams and ListGuardrailsResponse for the service layer.
/** Parameters for listing guardrails */ export interface ListGuardrailsParams { workspace_id?: string; organisation_id?: string; page_size?: number; current_page?: number; } /** Response from listing guardrails */ export interface ListGuardrailsResponse { data: Guardrail[]; total: number; } - Service implementation of listGuardrails — makes a GET request to /guardrails with query parameters for filtering and pagination.
export class GuardrailsService extends BaseService { /** * List all guardrails with optional filtering */ async listGuardrails( params?: ListGuardrailsParams, ): Promise<ListGuardrailsResponse> { return this.get<ListGuardrailsResponse>("/guardrails", { workspace_id: params?.workspace_id, organisation_id: params?.organisation_id, page_size: params?.page_size, current_page: params?.current_page, }); } - src/tools/index.ts:28-50 (registration)The registerGuardrailsTools function is wired into the tool domain registrars array under 'guardrails', and is called by registerAllTools.
type ToolRegistrar = (server: McpServer, service: PortkeyService) => void; const TOOL_DOMAIN_REGISTRARS = [ ["users", registerUsersTools], ["workspaces", registerWorkspacesTools], ["configs", registerConfigsTools], ["keys", registerKeysTools], ["collections", registerCollectionsTools], ["prompts", registerPromptsTools], ["analytics", registerAnalyticsTools], ["guardrails", registerGuardrailsTools], ["limits", registerLimitsTools], ["audit", registerAuditTools], ["labels", registerLabelsTools], ["partials", registerPartialsTools], ["tracing", registerTracingTools], ["logging", registerLoggingTools], ["providers", registerProvidersTools], ["integrations", registerIntegrationsTools], ["mcp-integrations", registerMcpIntegrationsTools], ["mcp-servers", registerMcpServersTools], ] as const satisfies readonly (readonly [string, ToolRegistrar])[];