Skip to content

Orcus2021/prompts-hub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Prompts Hub MCP Server

This is a tool that allows you to add commonly used prompts to an MCP server, enabling quick access to predefined prompt guidelines in editors that support MCP, such as Cursor.

Why Do You Need This Tool?

πŸ’° Reduce Repetitive Input Costs

In daily development work, we often need to repeatedly input the same prompt instructions:

  • Testing Guidelines: Having to re-describe testing specifications and best practices every time you write tests
  • Code Review: Repeatedly explaining code review standards and checklist items
  • Query Generation: Repeatedly explaining database query generation rules and format requirements
  • Documentation Writing: Repeatedly describing document structure and writing standards

After Using Prompts Hub:

  • βœ… One-Click Access: Quick access to predefined prompt guidelines
  • πŸ’― Language Optimization: Avoid repeatedly organizing language, directly use best practices
  • πŸ€– Smart Invocation: AI assistants automatically select and invoke appropriate prompt tools
  • 🎯 Context Awareness: Keyword triggers (like "write test") automatically provide relevant guidelines
  • πŸ”„ Seamless Integration: AI proactively provides tools without manual searching

MCP Configuration

Prerequisites

Before starting the configuration, you need to clone this project locally:

# Clone the project locally
git clone <repository-url>
cd prompts-hub

# Install dependencies
npm install

Step 1: Build the Project

npm run build

After building, compiled files will be generated in the dist/ directory.

Step 2: Get Project Absolute Path

You need to get the complete path of the project for use in MCP configuration:

# Execute in the project root directory to get the complete path
pwd

Note the output path, for example: /Users/username/projects/prompts

Step 3: Configure MCP Configuration File

Find MCP Configuration File Location

Depending on the editor you use, the MCP configuration file location may vary:

  • Cursor: ~/.cursor/mcp_servers.json
  • Claude Desktop: ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)
  • Other Editors: Please refer to the MCP configuration documentation for that editor

Add Configuration

Add the following configuration to your MCP configuration file:

{
  "mcpServers": {
    "prompts-hub": {
      "command": "node",
      "args": ["/complete/path/to/prompts/dist/index.js"]
    }
  }
}

Important Reminder:

  • Please replace /complete/path/to/prompts/dist/index.js with the actual path you obtained in Step 2
  • The path must point to the dist/index.js file
  • Use absolute paths to avoid path resolution issues

Update Tools

When you add new prompt tools, you need to rebuild:

npm run build

Then restart your editor to load the updated tools.

How to Create New Prompt Tools

Method 1: AI-Assisted Generation (Recommended)

You can directly provide prompt content to AI and reference @Plan.md to automatically generate tools:

Usage Example:

Here is my prompt, please refer to @Plan.md to add a tool:
# Component Unit Project Rule

This is a guideline about component unit testing specifications...

AI will automatically follow the detailed process in Plan.md to:

  • Analyze prompt requirements and parameters
  • Generate complete tool files
  • Handle all necessary configurations and registrations

πŸ’‘ Tip: Click Plan.md to view the complete tool creation process and specifications

Method 2: Manual Creation

We also provide automated scripts to simplify the tool creation process:

Step 1: Generate Tool Template

Use the built-in template generator to create new tool files:

npm run generate-template

Step 2: Edit Tool Content

Open the generated template file and modify it according to your needs:

  1. Modify Basic Information:

    const TOOL_NAME = "yourToolName"; // Change to your tool name
    const TOOL_DESCRIPTION = "Description of what this tool does"; // Tool description
  2. Configure Parameter Schema:

    • Tools with parameters: Modify serverInputSchema and toolSchema
    • Tools without parameters: Use empty object (refer to comments in template)
  3. Implement Tool Logic: Add your prompt content and logic in the runTool function

Step 3: Auto-Register Tool

Use the auto-registration command to add the new tool to index.ts:

npm run register-tool

Step 4: Build and Test

npm run build

Development Guide

Project Structure

prompts/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ tools/           # Prompt tool definitions
β”‚   β”‚   β”œβ”€β”€ index.ts     # Tool registration (auto-generated)
β”‚   β”‚   └── *.ts         # Individual tool files
β”‚   β”œβ”€β”€ types/           # TypeScript type definitions
β”‚   β”œβ”€β”€ utils/           # Utility functions
β”‚   └── toolRegistry.ts  # Tool registration center
β”œβ”€β”€ scripts/             # Automation scripts
β”‚   β”œβ”€β”€ template/        # Tool templates
β”‚   β”‚   └── toolTemplate.ts  # Tool template file
β”‚   β”œβ”€β”€ generateTemplate.js  # Template generation script
β”‚   └── updateToolsIndex.js  # Tool registration script
β”œβ”€β”€ package.json
└── README.md

Available NPM Scripts

# Build related
npm run build           # Complete build (type check + bundle)
npm run build:rollup    # Bundle only
npm run type-check      # TypeScript type check

# Development tools
npm run generate-template  # Generate new tool template
npm run register-tool     # Auto-register all tools to index.ts

Tool Examples

Example 1: Testing Guidelines (No Parameters)

import { ToolDefinition } from "../types/toolDefinition.js";
import { createResponse } from "../utils/createResponse.js";

const TOOL_NAME = "testingGuidelines";
const TOOL_DESCRIPTION = "Comprehensive testing guidelines for Jest";

const generateTestingGuidelines = () => `
# Testing Guidelines

## Test Structure
- Use describe blocks for grouping
- Use it/test for individual test cases
- Follow AAA pattern (Arrange, Act, Assert)

## Best Practices
- Write descriptive test names
- Test one thing at a time
- Use proper assertions
`;

async function runTestingGuidelines() {
  return createResponse(generateTestingGuidelines());
}

export const tool: ToolDefinition = {
  name: TOOL_NAME,
  description: TOOL_DESCRIPTION,
  schema: {
    type: "object",
    properties: {},
  },
  handler: async () => {
    return await runTestingGuidelines();
  },
};

Example 2: Generate Query (With Parameters)

import { z } from "zod";
import { ToolDefinition } from "../types/toolDefinition.js";
import { createResponse } from "../utils/createResponse.js";

const TOOL_NAME = "generateQuery";
const TOOL_DESCRIPTION =
  "Generate TypeScript Schema and Hook based on GraphQL Query";

const generateQuerySchema = z.object({
  graphPath: z.string().describe("The user-specified graph path"),
  query: z
    .string()
    .describe("The GraphQL Query to generate Schema and Hook from"),
});

const serverInputSchema = {
  type: "object",
  properties: {
    graphPath: {
      type: "string",
      description:
        "The user-specified graph path to generate the Schema and Hook from.",
    },
    query: {
      type: "string",
      description: "The GraphQL Query to generate the Schema and Hook from.",
    },
  },
  required: ["graphPath", "query"],
} as const;

const generateQueryPrompt = (graphPath: string, query: string) => `
# Generate TypeScript Schema and Hook

Graph Path: ${graphPath}
GraphQL Query:
\`\`\`graphql
${query}
\`\`\`

Please generate the corresponding TypeScript Schema and Hook based on the provided GraphQL Query.
`;

async function runGenerateQuery(graphPath: string, query: string) {
  return createResponse(generateQueryPrompt(graphPath, query));
}

export const tool: ToolDefinition = {
  name: TOOL_NAME,
  description: TOOL_DESCRIPTION,
  schema: serverInputSchema,
  handler: async (args: unknown) => {
    const validated = generateQuerySchema.parse(args);
    return await runGenerateQuery(validated.graphPath, validated.query);
  },
};

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published