Skip to main content
Glama

list_rules

Retrieve available project rules from promptz.dev to filter by tags and manage development guidelines without switching contexts.

Instructions

List available project rules from promptz.dev

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cursorNoPagination token for fetching the next set of results
tagsNoFilter rules by tags (e.g. ['CDK', 'React'])

Implementation Reference

  • The main handler function for the 'list_rules' tool. It extracts parameters from the MCP CallToolRequest, calls the listRules helper from graphql-client, maps the rules to a simplified format, and returns the result as a JSON string in CallToolResult format.
    export async function listRulesToolHandler(request: CallToolRequest): Promise<CallToolResult> { const nextToken = request.params.arguments?.nextToken as string | undefined; const tags = request.params.arguments?.tags as string[] | undefined; const response = await listRules(nextToken, tags); const rules = response.searchProjectRules.results; const result = { rules: rules.map((rule) => ({ name: rule.name, description: rule.description, tags: rule.tags || [], })), nextCursor: response.searchProjectRules.nextToken || undefined, }; return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; }
  • src/index.ts:64-83 (registration)
    Registration of the 'list_rules' tool in the ListToolsRequest handler, including the tool name, description, and input schema definition.
    { name: "list_rules", description: "List available project rules from promptz.dev", inputSchema: { type: "object", properties: { cursor: { type: "string", description: "Pagination token for fetching the next set of results", }, tags: { type: "array", items: { type: "string", }, description: "Filter rules by tags (e.g. ['CDK', 'React'])", }, }, }, },
  • src/index.ts:114-116 (registration)
    Dispatch to the listRulesToolHandler in the CallToolRequest switch statement.
    case "list_rules": { return await listRulesToolHandler(request); }
  • TypeScript interface defining the response shape from the listRules GraphQL query.
    export interface ListRulesResponse { searchProjectRules: { results: ProjectRule[]; nextToken?: string; }; }
  • Helper function that executes the GraphQL query to list rules, handling pagination and tags, and returns the typed response.
    export async function listRules(nextToken?: string, tags?: string[]): Promise<ListRulesResponse> { try { logger.info("[API] Listing rules" + (tags ? ` with tags: ${tags.join(", ")}` : "")); const { data, error } = await client.query( gql` ${SEARCH_RULES} `, { nextToken, tags }, ); if (error) { throw error; } return data; } catch (error) { logger.error(`[Error] Failed to list project rules: ${error instanceof Error ? error.message : String(error)}`); throw new Error(`Failed to list project rules: ${error instanceof Error ? error.message : String(error)}`); } }

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/cremich/promptz-mcp'

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