JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 259
  • Score
    100M100P100Q86061F
  • License MIT

MCP server for fetching and caching prompt templates from GitHub, GitLab, or local directories

Package Exports

  • mcp-prompt-fetcher
  • mcp-prompt-fetcher/server.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mcp-prompt-fetcher) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

MCP Prompt Fetcher

npm version License: MIT

A powerful MCP (Model Context Protocol) server that provides intelligent development prompts for Cursor, VS Code, and other IDE tools. Supports GitHub, GitLab, and local directory sources with automatic platform detection.

๐ŸŒŸ Features

  • ๐Ÿš€ Multi-Platform Support: GitHub, GitLab, and local directories
  • โšก Auto-Detection: Automatically detects platform from PROMPT_PATH
  • ๐Ÿ” Unified Authentication: Single GIT_TOKEN for both GitHub and GitLab
  • ๐ŸŽ›๏ธ Flexible Dialogs: Native system dialogs and web-based interfaces
  • ๐Ÿ“ฆ Zero Configuration: Works out-of-the-box with intelligent defaults
  • ๐Ÿ”„ Smart Caching: Optimized remote file fetching with TTL-based caching (3-hour default)
  • โšก Lazy Loading: Prompt content loaded on-demand to minimize API calls
  • ๐Ÿ›ก๏ธ Rate Limit Protection: Automatic fallback to cached data and graceful degradation
  • ๐ŸŽฏ Efficient API Usage: Only fetches file lists on startup, content on tool invocation
  • ๐ŸŒ Cross-Platform: Full macOS and Linux compatibility

๐Ÿ“ฆ Installation

# Install globally (recommended)
npm install -g mcp-prompt-fetcher

# Or install locally
npm install mcp-prompt-fetcher

โš™๏ธ Quick Setup

1๏ธโƒฃ Simple Configuration (Only 2 environment variables needed!)

Add to your IDE's MCP configuration file (e.g., ~/.cursor/mcp.json):

GitHub Repository

{
  "mcpServers": {
    "mcp-prompt-fetcher": {
      "command": "mcp-prompt-fetcher",
      "env": {
        "PROMPT_PATH": "username/repository",
        "GIT_TOKEN": "ghp_your_github_token_here"
      }
    }
  }
}

GitLab Repository

{
  "mcpServers": {
    "mcp-prompt-fetcher": {
      "command": "mcp-prompt-fetcher",
      "env": {
        "PROMPT_PATH": "https://gitlab.com/group/project",
        "GIT_TOKEN": "glpat-your_gitlab_token_here"
      }
    }
  }
}

Local Directory

{
  "mcpServers": {
    "mcp-prompt-fetcher": {
      "command": "mcp-prompt-fetcher",
      "env": {
        "PROMPT_PATH": "/path/to/your/prompts"
      }
    }
  }
}

Local Test by Source

{
  "osp-prompt": {
    "command": "node",
    "args": [
      "/Users/penuel/workspace_script/osp-prompt/dev-mcp/server.js"
    ],
    "env": {
      "PROMPT_PATH": "https://gitlab.com/test-group/test-repo/-/tree/master",
      "GIT_TOKEN": "your-actual-git-token",
      "CACHE_TTL_SEC": "10800",
      "AUTOMATED_MODE": "false",
      "DEBUG_LOG": "true"
    }
  }
}

2๏ธโƒฃ Universal URL Parser - Handle Any Complex URL!

Our advanced URL parser supports any complex GitLab and GitHub repository structure:

Complex URL Examples That Work:

# GitLab with multi-level projects and complex branches
"https://gitlab.com/Keccac256-evg/opensocial/osp-prompt/-/tree/master/dev-arch"
"https://gitlab.com/group/subgroup/project/-/tree/feature/new-ui/src/components"
"https://gitlab.com/company/team/service/-/tree/v1.2.3/docs/api"

# GitHub with deep nested paths and feature branches
"https://github.com/feast-dev/feast/tree/master/examples/java-demo/feature_repo/data"
"https://github.com/microsoft/vscode/tree/main/src/vs/editor/contrib"
"https://github.com/facebook/react/tree/feature/concurrent/packages/react/src"

Auto-Detection Results:

PROMPT_PATH Format Platform Parsed As
user/repo GitHub user/repo@main:dev-arch
https://github.com/owner/repo/tree/branch/path/to/files GitHub owner/repo@branch:path/to/files
https://gitlab.com/group/project/-/tree/branch/path GitLab group/project@branch:path
https://gitlab.com/a/b/c/-/tree/feature/x/deep/nested/path GitLab a/b/c@feature/x:deep/nested/path
/absolute/path Local Local filesystem
./relative/path Local Local filesystem

Smart Features:

  • โœ… Multi-level projects: group/subgroup/project
  • โœ… Complex branch names: feature/new-ui, hotfix/urgent-fix
  • โœ… Deep file paths: src/main/java/com/example/service
  • โœ… Version tags: v1.2.3, release/2024.1
  • โœ… Automatic API URL generation for both platforms

๐Ÿš€ Usage

Once configured, the following tools become available in your IDE:

  • dev-feature - ๐Ÿš€ Complete feature development (TDD workflow)
  • dev-design - ๐Ÿ“ System architecture design and planning
  • dev-refactor - ๐Ÿ”ง Code refactoring and optimization
  • dev-small - โšก Quick development and bug fixes
  • dev-tests - ๐Ÿงช Test coverage implementation (90%+ coverage)
  • dev-bugfix - ๐Ÿ› Precise problem analysis and minimal-impact fixes
  • dev-manual - ๐Ÿ“‹ Manual development type selection
  • dev-feedback - ๐Ÿ”„ Interactive step-by-step confirmation

Command Examples

dev-feature: Implement user authentication with email/phone login
dev-design: Design microservices architecture for e-commerce platform
dev-refactor: Improve code readability in user management module
dev-small: Fix login button display issue in Safari browser
dev-tests: Achieve 90%+ test coverage for user registration feature
dev-bugfix: Debug intermittent session loss during user login

๐Ÿ”ง Environment Variables

Variable Default Description
PROMPT_PATH (required) Platform will be auto-detected from this path
GIT_TOKEN (required for remote) GitHub (ghp_...) or GitLab (glpat-...) token
DIALOG_MODE auto Dialog mode: auto|native|browser
AUTOMATED_MODE true false=interactive confirmation, true=auto-execute
CACHE_TTL_SEC 86400 Cache TTL in seconds (24 hours)
FORCE_UPDATE false true=force remote fetch, bypass cache
DEBUG_LOG false Enable detailed logging

๐Ÿงช Testing

Verify Installation

# Test local mode
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' | PROMPT_PATH="./dev-arch" mcp-prompt-fetcher

# Test GitHub mode
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' | PROMPT_PATH="user/repo" GIT_TOKEN="your_token" mcp-prompt-fetcher

# Test GitLab mode
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' | PROMPT_PATH="https://gitlab.com/group/project" GIT_TOKEN="your_token" mcp-prompt-fetcher

Run Test Suite

npm test

install npm

<!-- ่‡ชๅŠจ้€’ๅขžๆ‰“ๅŒ…ๅนถๆ‰“git tag -->
npm version patch|minor|major
<!-- ๆœฌๅœฐๆ‰“ๅŒ…ๆŸฅ็œ‹ๅณๅฐ†ๅ‘ๅธƒ็š„ๅ†…ๅฎน -->
npm pack --dry-run 
<!-- ่ท‘ๆต‹่ฏ• + ๅฎก่ฎก่„šๆœฌ -->
npm run test:all  
npm run audit:security
<!-- ๅ‘ๅธƒๅŒ… -->
npm publish --access public
<!-- ๆŸฅ็œ‹็ป“ๆžœ -->
npm info mcp-prompt-fetcher

๐Ÿ“ Directory Structure

For local mode, your prompt directory should contain .prompt.md files:

dev-arch/
โ”œโ”€โ”€ feature.prompt.md      # โ†’ dev-feature tool
โ”œโ”€โ”€ design.prompt.md       # โ†’ dev-design tool
โ”œโ”€โ”€ refactor.prompt.md     # โ†’ dev-refactor tool
โ”œโ”€โ”€ small.prompt.md        # โ†’ dev-small tool
โ”œโ”€โ”€ tests.prompt.md        # โ†’ dev-tests tool
โ””โ”€โ”€ bugfix.prompt.md       # โ†’ dev-bugfix tool

๐ŸŽฏ Best Practices

Use Case Configuration Benefits
Local Development Local mode + Native dialogs Fast response, offline ready
Team Collaboration Remote mode + Browser dialogs Beautiful UI, centralized management
CI/CD Pipeline Remote mode + AUTOMATED_MODE=true No GUI dependencies
Step-by-Step Development Any mode + AUTOMATED_MODE=false Interactive confirmation

Token Permissions

GitHub Token Requirements:

  • public_repo (for public repositories)
  • repo (for private repositories)

GitLab Token Requirements:

  • read_repository
  • read_api

๐Ÿ” Troubleshooting

Common Issues

Problem Symptoms Solution
Tools not responding Click tool, no response 1. Check MCP config syntax
2. Restart IDE
3. Verify token validity
Dialog not showing Tool calls but no GUI 1. Check DIALOG_MODE setting
2. Try browser mode
3. Check system permissions
Invalid content returned Wrong prompt content 1. Check repository permissions
2. Verify branch and file paths
3. Clear cache
API Rate Limit (429 errors) Service starts with basic tools only Normal behavior - basic tools work offline, cached content used when available
Slow first-time loading Long delay on first tool call Expected - prompt content fetched on-demand, then cached for 3 hours

Cache Management

# Clear cache
rm -rf ~/.cache/prompts/*.md

# Or force update
export FORCE_UPDATE=true

Debug Mode

Set DEBUG_LOG=true to see detailed execution logs for troubleshooting.

๐Ÿ“‹ API Reference

MCP Methods

  • initialize - MCP protocol handshake
  • tools/list - Get available tools (config-driven)
  • tools/call - Execute specific tool

Tool Schema

Each tool follows this input schema:

{
  "type": "object",
  "properties": {
    "source": {
      "type": "string",
      "description": "Development requirements or task description"
    }
  },
  "required": ["source"]
}

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guide for details.

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™‹ Support


๐ŸŽ‰ Happy Coding with Intelligent Prompts!