mcp-prompt-server

jerfletcher/mcp-prompt-server

3.1

If you are the rightful owner of mcp-prompt-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

A Model Context Protocol (MCP) server that provides an extensible library of prompts and tools for AI assistants.

Tools
3
Resources
0
Prompts
0

MCP Prompt Server

A Model Context Protocol (MCP) server that provides an extensible library of prompts and tools for AI assistants.

Features

📝 Prompts

  • how-to-write-haiku: Instructions for writing haiku poems
  • summarize-text: Text summarization with customizable input
  • generate-idea: Creative idea generation for any topic
  • code-review: Structured code review checklist
  • api-documentation: API documentation template generator

🛠️ Tools

  • text-counter: Analyze text (characters, words, lines)
  • json-formatter: Format and validate JSON strings
  • timestamp-converter: Convert timestamps between formats

Installation

  1. Clone or download this repository
  2. No dependencies required - pure Node.js implementation

Usage

Available Scripts

npm run setup     # Automated VS Code MCP setup
npm start         # Start stdio MCP server
npm run serve     # Start HTTP server (port 3000)
npm test          # Run test suite

Standalone Testing

Run the server directly:

node mcpPromptsServer.js

HTTP Server

Start the HTTP server for web-based access:

npm run serve

Send POST requests to http://localhost:3000/mcp with JSON-RPC payloads:

curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "id": 1, "method": "prompts/list", "params": {}}'

Test with sample requests:

# List available prompts
echo '{"jsonrpc": "2.0", "id": 1, "method": "prompts/list", "params": {}}' | node mcpPromptsServer.js

# Get a specific prompt
echo '{"jsonrpc": "2.0", "id": 2, "method": "prompts/get", "params": {"name": "how-to-write-haiku"}}' | node mcpPromptsServer.js

# List available tools
echo '{"jsonrpc": "2.0", "id": 3, "method": "tools/list", "params": {}}' | node mcpPromptsServer.js

# Call a tool
echo '{"jsonrpc": "2.0", "id": 4, "method": "tools/call", "params": {"name": "text-counter", "arguments": {"text": "Hello world"}}}' | node mcpPromptsServer.js

VS Code MCP Server Integration

Quick Setup

Run the automated setup script:

npm run setup
# or
node setup.js

This script will:

  • Check prerequisites (Node.js, server file)
  • Update VS Code settings.json with MCP configuration
  • Make the server script executable
  • Test server functionality
  • Display next steps

Manual Configuration

Prerequisites

  • VS Code with MCP extension support
  • Node.js installed on your system

Configuration

  1. Add to VS Code MCP Configuration

    Open VS Code settings and add the MCP server configuration:

    {
      "mcp.servers": {
        "prompt-server": {
          "command": "node",
          "args": ["/absolute/path/to/mcpPromptsServer.js"],
          "env": {}
        }
      }
    }
    
  2. Alternative: Global Installation

    Make the script executable and add to PATH:

    chmod +x mcpPromptsServer.js
    sudo cp mcpPromptsServer.js /usr/local/bin/mcp-prompt-server
    

    Then configure in VS Code:

    {
      "mcp.servers": {
        "prompt-server": {
          "command": "mcp-prompt-server",
          "args": [],
          "env": {}
        }
      }
    }
    

Using in VS Code

Once configured, you can:

  1. Access Prompts: Use the command palette or MCP interface to:

    • List available prompts with prompts/list
    • Get specific prompts with prompts/get
    • Pass arguments to parameterized prompts
  2. Use Tools: Execute tools through the MCP interface:

    • Count text statistics with text-counter
    • Format JSON with json-formatter
    • Convert timestamps with timestamp-converter
  3. AI Assistant Integration: The server works with AI assistants that support MCP, providing context-aware prompts and utility tools.

API Reference

Prompts

prompts/list

Returns all available prompts.

prompts/get

Parameters:

  • name (required): Prompt name
  • arguments (optional): Object with prompt-specific arguments

Tools

tools/list

Returns all available tools with their schemas.

tools/call

Parameters:

  • name (required): Tool name
  • arguments (optional): Object with tool-specific arguments

Testing

Automated Testing

The project includes comprehensive tests for all prompts and tools:

npm test

Tests validate:

  • Structure: Required fields (name, description, content/inputSchema, handler)
  • Functionality: Tools execute without errors
  • Results: Output matches expected values (if provided)
  • Coverage: Warns about missing test configurations

Test Results

  • Passed: Tool/prompt works correctly
  • Failed: Error in execution or result validation
  • ⚠️ Warning: Missing test configuration

Extending the Server

Project Structure

mcp-prompt-server/
├── mcpPromptsServer.js    # Main MCP server
├── httpServer.js          # HTTP wrapper server
├── test.js               # Test runner
├── setup.js              # VS Code setup script
├── prompts/              # Prompt modules
│   ├── writing.js        # Writing-related prompts
│   ├── development.js    # Development prompts
│   └── text-analysis.js  # Text analysis prompts
└── tools/                # Tool modules
    ├── text-analysis.js  # Text analysis tools
    └── utilities.js      # Utility tools

Adding New Prompts

  1. Create or edit a file in the prompts/ directory
  2. Add your prompt with the required structure:
module.exports = {
    "your-prompt-name": {
        name: "your-prompt-name",
        description: "Description of your prompt",
        arguments: [
            { name: "param1", description: "Parameter description", required: true }
        ],
        content: `
            **Your Prompt Title:**
            
            Your prompt content here...
        `,
        llmInstruction: (args) => `LLM instruction with ${args.param1}`,
        test: { param1: "test value" }  // Test configuration
    }
};

Adding New Tools

  1. Create or edit a file in the tools/ directory
  2. Add your tool with the required structure:
module.exports = {
    "your-tool-name": {
        name: "your-tool-name",
        description: "Tool description",
        inputSchema: {
            type: "object",
            properties: {
                input: { type: "string", description: "Input description" }
            },
            required: ["input"]
        },
        handler: (args) => {
            // Your tool logic here
            return { result: "tool output" };
        },
        test: {
            input: "test input",
            expected: {
                result: "tool output"
            }
        }
    }
};

Test Configuration

Each prompt and tool should include a test property:

For Prompts:

test: { param1: "value1", param2: "value2" }

For Tools:

test: {
    input: "test input",
    expected: {  // Optional: validate specific output fields
        result: "expected result",
        status: "success"
    }
}

Validation Rules

  • Missing test: Tool/prompt without test property shows warning
  • Expected results: If expected is provided, actual output must match exactly
  • Required arguments: All required arguments must be present in test configuration

Troubleshooting

Common Issues

  1. Server not starting: Check Node.js installation and file permissions
  2. VS Code not detecting server: Verify the absolute path in configuration
  3. JSON parsing errors: Ensure requests follow JSON-RPC 2.0 format

Debug Mode

Monitor server logs:

node mcpPromptsServer.js 2>debug.log

The server logs to stderr, so responses won't be mixed with debug output.

License

ISC

Contributing

  1. Fork the repository
  2. Add your prompts/tools to the respective libraries
  3. Test with the standalone mode
  4. Submit a pull request

For questions or issues, please open an issue in the repository.