Skip to content

Feature/support custom mcp server#8

Merged
ZephyrDeng merged 3 commits intoZephyrDeng:masterfrom
MasonChow:feature/support-custom-mcp-server
Oct 9, 2025
Merged

Feature/support custom mcp server#8
ZephyrDeng merged 3 commits intoZephyrDeng:masterfrom
MasonChow:feature/support-custom-mcp-server

Conversation

@MasonChow
Copy link
Copy Markdown

No description provided.

zhoushunming 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.
Copilot AI review requested due to automatic review settings October 2, 2025 10:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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 ZephyrDeng merged commit b9c8001 into ZephyrDeng:master Oct 9, 2025
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants