Skip to main content
Glama

list_rules

Retrieve available project rules from promptz.dev to apply predefined guidelines and best practices for your development projects.

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 handler function that implements the core logic of the 'list_rules' tool. It extracts pagination and tag parameters from the request, calls the 'listRules' helper to fetch data from the GraphQL API, formats the rules into a JSON response, and returns it as MCP CallToolResult.
    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, specifying name, description, and input schema.
    { 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 structure of the listRules GraphQL response.
    export interface ListRulesResponse { searchProjectRules: { results: ProjectRule[]; nextToken?: string; }; }
  • Helper function that performs the GraphQL query to list project rules using the SEARCH_RULES query, handling errors and logging.
    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