|
|
@@ -18,6 +18,7 @@ config();
|
|
|
// Get configuration from environment variables
|
|
|
const GOGS_SERVER_URL = process.env.GOGS_SERVER_URL;
|
|
|
const GOGS_ACCESS_TOKEN = process.env.GOGS_ACCESS_TOKEN;
|
|
|
+const GOGS_REPO = process.env.GOGS_REPO;
|
|
|
const TRANSPORT_MODE = process.env.TRANSPORT_MODE || 'stdio';
|
|
|
const HTTP_PORT = parseInt(process.env.HTTP_PORT || '3000', 10);
|
|
|
const HTTP_HOST = process.env.HTTP_HOST || '0.0.0.0';
|
|
|
@@ -27,6 +28,21 @@ if (!GOGS_SERVER_URL) {
|
|
|
process.exit(1);
|
|
|
}
|
|
|
|
|
|
+// Validate GOGS_REPO format if set
|
|
|
+if (GOGS_REPO && !GOGS_REPO.includes('/')) {
|
|
|
+ console.error('Error: GOGS_REPO must be in format "owner/repo"');
|
|
|
+ process.exit(1);
|
|
|
+}
|
|
|
+
|
|
|
+// Parse GOGS_REPO into owner and repo
|
|
|
+let repoOwner: string | undefined;
|
|
|
+let repoName: string | undefined;
|
|
|
+if (GOGS_REPO) {
|
|
|
+ const parts = GOGS_REPO.split('/');
|
|
|
+ repoOwner = parts[0];
|
|
|
+ repoName = parts[1];
|
|
|
+}
|
|
|
+
|
|
|
// Initialize Gogs client
|
|
|
const gogsClient = new GogsClient({
|
|
|
serverUrl: GOGS_SERVER_URL,
|
|
|
@@ -34,7 +50,7 @@ const gogsClient = new GogsClient({
|
|
|
});
|
|
|
|
|
|
// Create MCP server with all tools and handlers
|
|
|
-const server = createMcpServer(gogsClient);
|
|
|
+const server = createMcpServer(gogsClient, repoOwner, repoName);
|
|
|
|
|
|
// Store http server instance for cleanup
|
|
|
let httpServer: HttpMcpServer | null = null;
|