Merge branch 'main' into map-traveler

This commit is contained in:
Masahiro Fukushima
2025-02-06 21:55:17 +09:00
committed by GitHub
4 changed files with 11 additions and 3 deletions

View File

@@ -1,10 +1,12 @@
import { getUserAgent } from "universal-user-agent";
import { createGitHubError } from "./errors.js"; import { createGitHubError } from "./errors.js";
import { VERSION } from "./version.js";
type RequestOptions = { type RequestOptions = {
method?: string; method?: string;
body?: unknown; body?: unknown;
headers?: Record<string, string>; headers?: Record<string, string>;
}; }
async function parseResponseBody(response: Response): Promise<unknown> { async function parseResponseBody(response: Response): Promise<unknown> {
const contentType = response.headers.get("content-type"); const contentType = response.headers.get("content-type");
@@ -24,6 +26,8 @@ export function buildUrl(baseUrl: string, params: Record<string, string | number
return url.toString(); return url.toString();
} }
const USER_AGENT = `modelcontextprotocol/servers/github/v${VERSION} ${getUserAgent()}`;
export async function githubRequest( export async function githubRequest(
url: string, url: string,
options: RequestOptions = {} options: RequestOptions = {}
@@ -31,6 +35,7 @@ export async function githubRequest(
const headers: Record<string, string> = { const headers: Record<string, string> = {
"Accept": "application/vnd.github.v3+json", "Accept": "application/vnd.github.v3+json",
"Content-Type": "application/json", "Content-Type": "application/json",
"User-Agent": USER_AGENT,
...options.headers, ...options.headers,
}; };

View File

@@ -0,0 +1 @@
export const VERSION = "0.6.2";

View File

@@ -25,11 +25,12 @@ import {
GitHubConflictError, GitHubConflictError,
isGitHubError, isGitHubError,
} from './common/errors.js'; } from './common/errors.js';
import { VERSION } from "./common/version.js";
const server = new Server( const server = new Server(
{ {
name: "github-mcp-server", name: "github-mcp-server",
version: "0.1.0", version: VERSION,
}, },
{ {
capabilities: { capabilities: {

View File

@@ -23,6 +23,7 @@
"@types/node": "^22", "@types/node": "^22",
"@types/node-fetch": "^2.6.12", "@types/node-fetch": "^2.6.12",
"node-fetch": "^3.3.2", "node-fetch": "^3.3.2",
"universal-user-agent": "^7.0.2",
"zod": "^3.22.4", "zod": "^3.22.4",
"zod-to-json-schema": "^3.23.5" "zod-to-json-schema": "^3.23.5"
}, },
@@ -30,4 +31,4 @@
"shx": "^0.3.4", "shx": "^0.3.4",
"typescript": "^5.6.2" "typescript": "^5.6.2"
} }
} }