Feature/support custom mcp server#8
Merged
ZephyrDeng merged 3 commits intoZephyrDeng:masterfrom Oct 9, 2025
Merged
Conversation
added 2 commits
October 2, 2025 18:05
… registration - Updated package.json to include module and types exports for better compatibility. - Removed private token validation in GitlabConfig, allowing dynamic token passing via headers. - Introduced gitlab-tools-sdk.ts for centralized GitLab tool registration and management. - Implemented dynamic GitLab client creation based on request context in various tools. - Added GitLabSession type for improved session management and authentication. - Refactored tools to utilize the new GitLab client factory for API requests. - Updated tsconfig.json to include declaration and source maps for better type support. - Deprecated old tool registration methods in favor of the new centralized approach.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements support for custom MCP server functionality with dynamic session-based authentication for the GitLab MCP server. The changes enable HTTP stream mode with dynamic token authentication via HTTP headers, making the server more flexible for multi-tenant scenarios.
Key Changes
- Dynamic GitLab client creation based on session context
- HTTP header-based authentication for tokens and base URLs
- Refactored configuration to support optional tokens/URLs in HTTP stream mode
Reviewed Changes
Copilot reviewed 21 out of 22 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/typeGuards.ts | Type guards for session data validation and extraction |
| src/utils/gitlabClientFactory.ts | Factory functions for creating GitLab clients with dynamic configuration |
| src/utils/gitlabApiClientInstance.ts | Re-exports factory functions for backward compatibility |
| src/types/GitLabTool.ts | Base type definition for GitLab tools |
| src/types/GitLabSession.ts | Session interface for authentication data |
| src/tools/*.ts | Updated tools to use context-based client creation |
| src/index.ts | Added authentication handler for HTTP headers |
| src/gitlab-tools-sdk.ts | New SDK module for tool registration |
| src/config/GitlabConfig.ts | Updated to allow empty base URLs in HTTP stream mode |
| package.json | Added module exports configuration |
| README*.md | Updated documentation for new features |
ZephyrDeng
reviewed
Oct 9, 2025
ZephyrDeng
reviewed
Oct 9, 2025
ZephyrDeng
reviewed
Oct 9, 2025
Address all review comments from PR ZephyrDeng#8: 1. Code Quality (Copilot suggestions): - Translate Chinese comments to English for consistency - Update comments in gitlabApiClientInstance.ts, GitLabTool.ts, and GitlabConfig.ts 2. Error Handling (ZephyrDeng suggestions): - Add validation in gitlabClientFactory.ts with clear error messages - Validate token and baseUrl availability with helpful hints - Support fallback to environment variables 3. Type Safety (ZephyrDeng suggestions): - Remove overly permissive index signature from GitLabSession - Create GitLabSessionWithExtras type for better type safety - Maintain flexibility while providing strict typing 4. Security & Validation (ZephyrDeng suggestions): - Add token format validation (minimum 20 characters) - Add URL format validation in authenticate function - Provide early error detection for invalid configurations All changes maintain backward compatibility and improve code quality. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
ZephyrDeng
added a commit
that referenced
this pull request
Oct 10, 2025
PR #8 引入了工厂模式(createGitlabClientFromContext)替代单例模式, 导致测试中的 mock 失效。本次修复: - 更新 6 个测试文件的 mock 策略 - 使用 createGitlabClientFromContext 工厂函数 mock - 添加正确的 TypeScript 类型注解 - 所有测试通过 (47 passed, 10 suites)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.