mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-20 00:53:24 +02:00
Merge branch 'main' into add-github-enterprise-mcp
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
|||||||
} from "@modelcontextprotocol/sdk/types.js";
|
} from "@modelcontextprotocol/sdk/types.js";
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { zodToJsonSchema } from 'zod-to-json-schema';
|
import { zodToJsonSchema } from 'zod-to-json-schema';
|
||||||
|
import fetch, { Request, Response } from 'node-fetch';
|
||||||
|
|
||||||
import * as repository from './operations/repository.js';
|
import * as repository from './operations/repository.js';
|
||||||
import * as files from './operations/files.js';
|
import * as files from './operations/files.js';
|
||||||
@@ -27,6 +28,11 @@ import {
|
|||||||
} from './common/errors.js';
|
} from './common/errors.js';
|
||||||
import { VERSION } from "./common/version.js";
|
import { VERSION } from "./common/version.js";
|
||||||
|
|
||||||
|
// If fetch doesn't exist in global scope, add it
|
||||||
|
if (!globalThis.fetch) {
|
||||||
|
globalThis.fetch = fetch as unknown as typeof global.fetch;
|
||||||
|
}
|
||||||
|
|
||||||
const server = new Server(
|
const server = new Server(
|
||||||
{
|
{
|
||||||
name: "github-mcp-server",
|
name: "github-mcp-server",
|
||||||
@@ -293,10 +299,39 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|||||||
case "create_issue": {
|
case "create_issue": {
|
||||||
const args = issues.CreateIssueSchema.parse(request.params.arguments);
|
const args = issues.CreateIssueSchema.parse(request.params.arguments);
|
||||||
const { owner, repo, ...options } = args;
|
const { owner, repo, ...options } = args;
|
||||||
const issue = await issues.createIssue(owner, repo, options);
|
|
||||||
return {
|
try {
|
||||||
content: [{ type: "text", text: JSON.stringify(issue, null, 2) }],
|
console.error(`[DEBUG] Attempting to create issue in ${owner}/${repo}`);
|
||||||
};
|
console.error(`[DEBUG] Issue options:`, JSON.stringify(options, null, 2));
|
||||||
|
|
||||||
|
const issue = await issues.createIssue(owner, repo, options);
|
||||||
|
|
||||||
|
console.error(`[DEBUG] Issue created successfully`);
|
||||||
|
return {
|
||||||
|
content: [{ type: "text", text: JSON.stringify(issue, null, 2) }],
|
||||||
|
};
|
||||||
|
} catch (err) {
|
||||||
|
// Type guard for Error objects
|
||||||
|
const error = err instanceof Error ? err : new Error(String(err));
|
||||||
|
|
||||||
|
console.error(`[ERROR] Failed to create issue:`, error);
|
||||||
|
|
||||||
|
if (error instanceof GitHubResourceNotFoundError) {
|
||||||
|
throw new Error(
|
||||||
|
`Repository '${owner}/${repo}' not found. Please verify:\n` +
|
||||||
|
`1. The repository exists\n` +
|
||||||
|
`2. You have correct access permissions\n` +
|
||||||
|
`3. The owner and repository names are spelled correctly`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Safely access error properties
|
||||||
|
throw new Error(
|
||||||
|
`Failed to create issue: ${error.message}${
|
||||||
|
error.stack ? `\nStack: ${error.stack}` : ''
|
||||||
|
}`
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case "create_pull_request": {
|
case "create_pull_request": {
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ export const GitLabRepositorySchema = z.object({
|
|||||||
name: z.string(),
|
name: z.string(),
|
||||||
path_with_namespace: z.string(), // Changed from full_name to match GitLab API
|
path_with_namespace: z.string(), // Changed from full_name to match GitLab API
|
||||||
visibility: z.string(), // Changed from private to match GitLab API
|
visibility: z.string(), // Changed from private to match GitLab API
|
||||||
owner: GitLabOwnerSchema,
|
owner: GitLabOwnerSchema.optional(),
|
||||||
web_url: z.string(), // Changed from html_url to match GitLab API
|
web_url: z.string(), // Changed from html_url to match GitLab API
|
||||||
description: z.string().nullable(),
|
description: z.string().nullable(),
|
||||||
fork: z.boolean(),
|
fork: z.boolean().optional(),
|
||||||
ssh_url_to_repo: z.string(), // Changed from ssh_url to match GitLab API
|
ssh_url_to_repo: z.string(), // Changed from ssh_url to match GitLab API
|
||||||
http_url_to_repo: z.string(), // Changed from clone_url to match GitLab API
|
http_url_to_repo: z.string(), // Changed from clone_url to match GitLab API
|
||||||
created_at: z.string(),
|
created_at: z.string(),
|
||||||
@@ -218,12 +218,12 @@ export const GitLabMergeRequestSchema = z.object({
|
|||||||
title: z.string(),
|
title: z.string(),
|
||||||
description: z.string(), // Changed from body to match GitLab API
|
description: z.string(), // Changed from body to match GitLab API
|
||||||
state: z.string(),
|
state: z.string(),
|
||||||
merged: z.boolean(),
|
merged: z.boolean().optional(),
|
||||||
author: GitLabUserSchema,
|
author: GitLabUserSchema,
|
||||||
assignees: z.array(GitLabUserSchema),
|
assignees: z.array(GitLabUserSchema),
|
||||||
source_branch: z.string(), // Changed from head to match GitLab API
|
source_branch: z.string(), // Changed from head to match GitLab API
|
||||||
target_branch: z.string(), // Changed from base to match GitLab API
|
target_branch: z.string(), // Changed from base to match GitLab API
|
||||||
diff_refs: GitLabMergeRequestDiffRefSchema,
|
diff_refs: GitLabMergeRequestDiffRefSchema.nullable(),
|
||||||
web_url: z.string(), // Changed from html_url to match GitLab API
|
web_url: z.string(), // Changed from html_url to match GitLab API
|
||||||
created_at: z.string(),
|
created_at: z.string(),
|
||||||
updated_at: z.string(),
|
updated_at: z.string(),
|
||||||
|
|||||||
Reference in New Issue
Block a user