Skip to content

codenjoyme/mcpyrex-javascript

Repository files navigation

Extending GitHub Copilot with JavaScript/Node.js via MCP

This project demonstrates how to extend GitHub Copilot capabilities using JavaScript/Node.js and the Model Context Protocol (MCP), allowing for more deterministic and powerful interactions with the LLM.

Project Overview

As a GitHub Copilot trainer, I've observed its impressive evolution. However, I've always wanted to access GitHub Copilot's internals to build more complex transformation chains. This project shows how to achieve that goal by leveraging MCP (Model Context Protocol) and custom MCP tools.

While GitHub Copilot repository custom instructions feature improved customization options, the introduction of the MCP protocol opened new possibilities for extending Copilot's functionality through custom MCP servers.

The Problem

Instruction files are not always deterministic - they need to be fine-tuned when new LLM versions are released to reduce hallucinations. LLMs often struggle with precise text manipulations, sometimes creatively reinterpreting tasks and adding unwanted artifacts. What we need is a way to inject deterministic logic into our instructions.

The Solution

This project demonstrates a solution through:

  1. JavaScript/Node.js scripts installed on the local machine.
  2. Custom MCP server configuration through .vscode/mcp.json
  3. Custom tools defined in the tools/ directory

With this setup, GitHub Copilot gains access to new, well-documented tools that it can see as part of your project. When you ask Copilot to "create a tool that does X", it can generate a solution very close to what you need. You simply accept its changes and restart MCP to get a new deterministic tool for your specific logic.

Data Security

⚠️ Important: Please review the Security Disclaimer before using this tool in production environments.

This document outlines potential data leak scenarios and provides guidance on risk mitigation when working with this tool.

Getting Started

🚧 Status: Baby Step 1 - Basic MCP Server ✅

Current Installation (Manual)

# 1. Clone or download the project
# 2. Navigate to .mcp-javascript folder
cd .mcp-javascript

# 3. Install dependencies
npm install

# 4. Copy environment template (optional for now)
copy build\config\.env .env

# 5. Test the server
npm start
# Press Ctrl+C to stop

# 6. Check logs
Get-Content logs\mcp_server.log -Tail 20

MCP Configuration

For VS Code:

  1. Copy config to workspace root:
    copy build\config\.vscode\mcp.json ..\..\.vscode\mcp.json
  2. Restart VS Code
  3. The MCP server should appear in the MCP servers list

For Cursor:

  1. Copy build/config/.cursor/mcp.json content to Cursor Settings
  2. Go to Cursor Settings → Features → Enable MCP
  3. Paste the configuration
  4. Restart Cursor

Note: The configs already include GitHub Copilot MCP server integration.

What's Working Now

Basic MCP Server - Responds to MCP protocol
Logging System - All events logged to logs/mcp_server.log
Configuration Templates - Ready for VS Code and Cursor
Tools - Coming in next steps
Pipeline Engine - Coming soon
CLI Runner - Coming soon

Testing

Test 1: Run the server directly

npm start

You should see nothing in the console (stdio is used for MCP protocol). Press Ctrl+C to stop the server.

Then check the log file:

Get-Content logs\mcp_server.log -Tail 20

You should see:

2025-11-14 XX:XX:XX - INFO - Logging initialized for mcp_server
2025-11-14 XX:XX:XX - INFO - Starting MCP JavaScript Server
2025-11-14 XX:XX:XX - INFO - Node.js executable: C:\Java\nodejs\node.exe
2025-11-14 XX:XX:XX - INFO - Node.js version: v20.15.0
2025-11-14 XX:XX:XX - INFO - Current directory: C:\Java\CopipotTraining\mcpyrex\.mcp-javascript
2025-11-14 XX:XX:XX - INFO - All modules imported successfully
2025-11-14 XX:XX:XX - INFO - Starting MCP server with stdio transport
2025-11-14 XX:XX:XX - INFO - Registering MCP handlers...
2025-11-14 XX:XX:XX - INFO - MCP server configured successfully
2025-11-14 XX:XX:XX - INFO - Phase 1: Basic Infrastructure - COMPLETE ✅
2025-11-14 XX:XX:XX - INFO - Phase 2: MCP Server Core - COMPLETE ✅
2025-11-14 XX:XX:XX - INFO - Starting MCP server...
2025-11-14 XX:XX:XX - INFO - MCP server started successfully and listening on stdio
2025-11-14 XX:XX:XX - INFO - Server is ready to accept requests

✅ If you see these logs - Test 1 PASSED!

Test 2: CLI Runner (run.js)

The run.js script provides a standalone tool runner for testing tools without MCP overhead (like Python's run.py and .NET's Run.cs).

# Show usage help
node run.js

# List available tools
node run.js list

# Run a specific tool
node run.js run lng_count_words '{"input_text":"Hello world"}'

# Get tool schema
node run.js schema lng_count_words

# Run tools in batch
node run.js batch lng_count_words '{"input_text":"test"}' lng_math_calculator '{"expression":"2+2"}'

# Start in daemon mode (keeps process alive)
node run.js run --daemon lng_webhook_server '{"operation":"start", "name":"test"}'

# Batch daemon mode
node run.js batch --daemon lng_webhook_server '{"operation":"start"}' lng_webhook_server '{"operation":"list"}'

# Install dependencies for specific tools
node run.js install_dependencies lng_email_client

# Analyze npm packages
node run.js analyze_libs express react axios

Status:

  • ✅ CLI runner fully implemented
  • ✅ Structure matches Python/C# versions exactly
  • ⏳ Tool Registry and tools implementation in progress

✅ If you see proper usage output - Test 2 PASSED!

Test 2: Configure MCP in VS Code/Cursor

See "MCP Configuration" section above.

Test 3: Verify MCP Protocol

Once configured in VS Code/Cursor, the server should:

  • Start automatically when you open the IDE
  • Show up in MCP servers list
  • Respond to list_tools request (returns empty list for now)
  • Not crash when called

Check logs after IDE starts:

Get-Content logs\mcp_server.log -Tail 30

Look for:

INFO - Received list_tools request

✅ If you see this - Test 3 PASSED! Server is working with MCP protocol!

MCP Configuration Details

Enabling/Disabling MCP in VS Code

To control whether MCP (Model Context Protocol) is enabled or disabled, modify ${workspaceFolder}/.vscode/settings.json:

To Enable MCP:

{
    "chat.mcp.enabled": true,
    "github.copilot.chat.codeGeneration.useInstructionFiles": false
}

To Disable MCP:

{
    "chat.mcp.enabled": false,
    "github.copilot.chat.codeGeneration.useInstructionFiles": true
}

mcp.json

{
  "servers": {
    "mcpyrex-javascript":{
      "type": "stdio",
      "command": "node",
      "args": ["${workspaceFolder}\\.mcp-javascript\\server.js"]
    },
    "github": {
      "type": "http",
      "url": "https://api.githubcopilot.com/mcp/"
    }
  }
}

API Keys

API keys and other credentials should be stored in a .env file (template in build/config/.env).

Custom Tools (Coming Soon)

🚧 Tools will be implemented in upcoming baby steps:

  • lng_batch_run - Advanced pipeline execution
  • lng_count_words - Word counting demonstration
  • lng_get_tools_info - Tools information retrieval
  • And more in tools/ directory

Running Tools in Terminal (Coming Soon)

🚧 CLI runner (run.js) will be implemented in the next baby step:

node run.js list
node run.js schema lng_count_words
node run.js run lng_count_words '{"input_text":"Hello world"}'

What's Next

After Baby Step 1 works:

  • Implement run.js for CLI testing
  • Add first simple tool (lng_count_words)
  • Add ToolRegistry
  • Implement StateManager
  • Add Pipeline engine
  • Port all tools from Python/C# versions

Troubleshooting

Server won't start?

  • Check Node.js version: node --version (need 18+)
  • Check logs: Get-Content logs\mcp_server.log
  • Try: npm install again

No logs directory?

  • It will be created automatically on first run

VS Code/Cursor doesn't see the server?

  • Check the path in mcp.json uses ${workspaceFolder}
  • Restart VS Code/Cursor after changing config
  • Check VS Code Developer Tools console for MCP errors

Original Source

This project is a JavaScript/Node.js port based on:

Blog post: Как расширить GithubCopilot с помощью Python и Langchain через MCP

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors