Create an mcp server for github
- User
Create an mcp server for github
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Create an mcp server for github
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
I can help you set up a Minecraft Protocol (MCP) server that integrates with GitHub. Here's a basic implementation using Node.js:
const mc = require('minecraft-protocol');
const axios = require('axios');
const fs = require('fs');
const path = require('path');
// GitHub integration configuration
const GITHUB_TOKEN = 'your_github_token';
const GITHUB_REPO = 'username/repository';
// Minecraft server configuration
const server = mc.createServer({
'online-mode': true,
encryption: true,
host: '0.0.0.0',
port: 25565,
version: '1.19.2',
motd: 'GitHub Integration Server'
});
console.log('Server started on port 25565');
// GitHub API helper
const github = axios.create({
baseURL: 'https://api.github.com',
headers: {
'Authorization': `token ${GITHUB_TOKEN}`,
'Accept': 'application/vnd.github.v3+json'
}
});
// Handle player connections
server.on('login', async (client) => {
console.log(`Player ${client.username} connected`);
// Send welcome message
client.write('chat', {
message: JSON.stringify({
text: `Welcome to the GitHub integration server, ${client.username}!`,
color: 'green'
}),
position: 0,
sender: '0'
});
// Set up command handling
client.on('chat', async (data) => {
const message = data.message;
if (message.startsWith('!github')) {
const args = message.split(' ');
const command = args[1];
switch(command) {
case 'issues':
const issues = await getIssues();
sendMessage(client, `Found ${issues.length} open issues in ${GITHUB_REPO}`);
issues.forEach((issue, i) => {
if (i < 5) { // Limit to 5 issues to avoid spam
sendMessage(client, `#${issue.number}: ${issue.title}`);
}
});
break;
case 'commits':
const commits = await getCommits();
sendMessage(client, `Recent commits in ${GITHUB_REPO}:`);
commits.forEach((commit, i) => {
if (i < 5) {
sendMessage(client, `${commit.sha.substring(0, 7)}: ${commit.commit.message}`);
}
});
break;
default:
sendMessage(client, 'Available commands: !github issues, !github commits');
}
}
});
});
// GitHub API functions
async function getIssues() {
try {
const response = await github.get(`/repos/${GITHUB_REPO}/issues`);
return response.data;
} catch (error) {
console.error('Error fetching issues:', error.message);
return [];
}
}
async function getCommits() {
try {
const response = await github.get(`/repos/${GITHUB_REPO}/commits`);
return response.data;
} catch (error) {
console.error('Error fetching commits:', error.message);
return [];
}
}
// Helper to send formatted messages
function sendMessage(client, text) {
client.write('chat', {
message: JSON.stringify({
text: text,
color: 'aqua'
}),
position: 0,
sender: '0'
});
}
Would you like me to explain or break down this code?