Content
# MCP Prompt Server
[English Version](README_EN.md)
This is a server based on the Model Context Protocol (MCP) that provides preset prompt templates according to user task requirements, helping Cline/Cursor/Windsurf... execute various tasks more efficiently. The server returns the preset prompts as tools to be better utilized in editors like Cursor and Windsurf.
## Features
- Provides preset prompt templates for tasks such as code review, API documentation generation, code refactoring, etc.
- Offers all prompt templates as MCP tools rather than in MCP prompts format.
- Supports dynamic parameter replacement, making prompt templates more flexible.
- Allows developers to freely add and modify prompt templates.
- Provides a tool API to reload prompts and query available prompts.
- Optimized specifically for editors like Cursor and Windsurf, offering a better integration experience.
## Directory Structure
```
prompt-server/
├── package.json # Project dependencies and scripts
├── src/ # Source code directory
│ ├── index.js # Server entry file
│ └── prompts/ # Preset prompt templates directory
│ ├── code_review.yaml
│ ├── api_documentation.yaml
│ ├── code_refactoring.yaml
│ ├── test_case_generator.yaml
│ └── project_architecture.yaml
└── README.md # Project documentation
```
## Installation and Usage
1. Install dependencies:
```bash
cd prompt-server
npm install
```
2. Start the server:
```bash
npm start
```
The server will run on standard input/output and can be connected to by Cursor, Windsurf, or other MCP clients.
## Adding New Prompt Templates
You can create new prompt templates by adding new YAML or JSON files in the `src/prompts` directory. Each template file should contain the following content:
```yaml
name: prompt_name # Unique identifier for calling this prompt
description: prompt description # Description of the prompt's functionality
arguments: # List of parameters (optional)
- name: arg_name # Parameter name
description: arg description # Parameter description
required: true/false # Whether it is required
messages: # List of prompt messages
- role: user/assistant # Message role
content:
type: text # Content type
text: | # Text content, can include parameter placeholders {{arg_name}}
Your prompt text here...
```
After adding a new file, the server will automatically load it the next time it starts, or you can use the `reload_prompts` tool to reload all prompts.
## Usage Examples
### Calling the Code Review Tool in Cursor or Windsurf
```json
{
"name": "code_review",
"arguments": {
"language": "javascript",
"code": "function add(a, b) { return a + b; }"
}
}
```
### Calling the API Documentation Generation Tool in Cursor or Windsurf
```json
{
"name": "api_documentation",
"arguments": {
"language": "python",
"code": "def process_data(data, options=None):\n # Process data\n return result",
"format": "markdown"
}
}
```
## Tool API
The server provides the following management tools:
- `reload_prompts`: Reload all preset prompts
- `get_prompt_names`: Retrieve all available prompt names
Additionally, all prompt templates defined in the `src/prompts` directory will be provided as tools to the client.
## Integration with Editors
### Cursor
In Cursor, you need to edit the MCP configuration file:
1. Locate or create the MCP configuration file for Cursor (usually located in the `~/.cursor/` directory).
2. Add the following content:
```json
{
"servers": [
{
"name": "Prompt Server",
"command": ["node", "/path/to/prompt-server/src/index.js"],
"transport": "stdio",
"initialization_options": {}
}
]
}
```
Make sure to replace `/path/to/prompt-server` with your actual project path.
3. Save the configuration and restart the editor.
4. You should now see all available prompt tools in the tool panel.
### Windsurf
In Windsurf, access the MCP configuration as follows:
1. Navigate to Windsurf - Settings > Advanced Settings, or
2. Use the command palette > Open Windsurf settings page.
3. Scroll to the Cascade section, where you will see the option to add a new server.
4. Click the "Add Server" button, then select "Add Custom Server+".
5. Alternatively, you can directly edit the `~/.codeium/windsurf/mcp_config.json` file and add the following content:
```json
{
"mcpServers": {
"prompt-server": {
"command": "node",
"args": [
"/path/to/prompt-server/src/index.js"
],
"transport": "stdio"
}
}
}
```
Make sure to replace `/path/to/prompt-server` with your actual project path.
6. After adding the server, click the refresh button.
7. You should now see all available prompt tools in the tool panel.
## Extension Suggestions
1. Add more prompt templates for specialized fields.
2. Implement prompt version control.
3. Add prompt categorization and tagging.
4. Implement prompt usage statistics and analysis.
5. Add a user feedback mechanism.