Skip to main content
Glama

get_rule

Retrieve a specific project rule by name from promptz.dev to access prompts without context switching in development workflows.

Instructions

Get a specific project rule by name

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameNoName of the rule to retrieve

Implementation Reference

  • The primary handler function for the "get_rule" tool. It validates the input name, fetches the rule via getRuleByName, formats the response data, and returns it as a JSON text content block.
    export async function getRuleToolHandler(request: CallToolRequest): Promise<CallToolResult> { const name = request.params.arguments?.name as string | undefined; if (!name) { throw new Error("Rule name is required"); } const rule = await getRuleByName(name); if (!rule) { throw new Error(`Rule not found: ${name}`); } const ruleData = { name: rule.name, description: rule.description, tags: rule.tags || [], author: rule.author?.displayName, content: rule.content, }; return { content: [ { type: "text", text: JSON.stringify(ruleData, null, 2), }, ], }; }
  • src/index.ts:117-119 (registration)
    Registration in the CallToolRequest switch statement, dispatching calls to the get_rule tool to its handler function.
    case "get_rule": { return await getRuleToolHandler(request); }
  • src/index.ts:84-96 (registration)
    Tool registration in the ListToolsRequest handler, defining the name, description, and input schema for the "get_rule" tool.
    { name: "get_rule", description: "Get a specific project rule by name", inputSchema: { type: "object", properties: { name: { type: "string", description: "Name of the rule to retrieve", }, }, }, },
  • Supporting helper function that executes the GraphQL query to fetch a project rule by its name, used by the tool handler.
    export async function getRuleByName(name: string): Promise<ProjectRule | null> { try { logger.info(`[API] Getting rule by name: ${name}`); // Search for prompts with the exact name const { data, error } = await client.query( gql` ${GET_RULE_BY_NAME} `, { name }, ); if (error) { throw error; } const rules = data.listRuleByName.items; if (rules.length === 0) { return null; } return rules[0]; } catch (error) { logger.error(`[Error] Failed to get rule by name: ${error instanceof Error ? error.message : String(error)}`); throw new Error(`Failed to get rule by name: ${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