Skip to content

[WIP] MCP Client Configuration and Per User Session#21

Closed
Copilot wants to merge 5 commits intomasterfrom
copilot/fix-19
Closed

[WIP] MCP Client Configuration and Per User Session#21
Copilot wants to merge 5 commits intomasterfrom
copilot/fix-19

Conversation

Copy link
Contributor

Copilot AI commented Jul 18, 2025

Implementing per-user MCP client configuration to allow users to have personalized MCP server configurations with secure parameter storage.

MCP Configuration Page

Completed Implementation:

  • Create UserMcpInput model for storing user-specific MCP input parameters
  • Add UserMcpInput to database context and create migration
  • Create UserMcpPluginProvider service for per-user MCP plugin loading
  • Add parameter replacement logic to substitute ${input:key} placeholders
  • Update service registration to use scoped MCP services per user
  • Create UI component for users to configure MCP input parameters
  • Add UserMcpInputService for managing user MCP configurations
  • Add EncryptionService for secure storage of sensitive parameters
  • Update AIService to support user-specific MCP plugins initialization
  • Fix nullability warnings in MCP plugin providers
  • Test the implementation with existing MCP server configurations
  • Verify security of sensitive parameter storage
  • Validate parameter replacement functionality with comprehensive tests

Key Changes Made:

Database & Models:

  • Added UserMcpInput model with encrypted value storage per user
  • Created database migration (AddUserMcpInputs) for user MCP input storage
  • Enhanced user data isolation and security

Security Implementation:

  • Implemented EncryptionService for secure parameter encryption/decryption using AES-256
  • Input parameters are encrypted before database storage
  • Each user's MCP inputs are isolated and only accessible to that user
  • Sensitive fields are clearly marked in the UI with password input types

Core Services:

  • Created UserMcpInputService for managing user MCP input values with placeholder replacement
  • Developed UserMcpPluginProvider for per-user MCP plugin initialization with parameter substitution
  • Added UserKernelFactory to create kernels with user-specific plugins
  • Modified AIService to support dynamic kernel updates with user MCP plugins

Parameter Replacement Logic:

  • Implements ${input:key} placeholder substitution in:
    • Environment variables for STDIO servers
    • Headers for SSE servers
    • Command arguments
    • URLs and connection strings
  • Supports string, dictionary, and list replacement operations
  • Validated with comprehensive tests: All parameter replacement scenarios pass ✓

User Interface:

  • Created /mcp-config page for users to configure their MCP parameters
  • Clean, user-friendly interface with security indicators
  • Added navigation link to MCP configuration in the main menu
  • Handles scenarios with no configured MCP inputs gracefully

Integration & Compatibility:

  • Updated service registration to support user-scoped MCP functionality
  • Integrated user MCP plugin initialization into the Home page lifecycle
  • Enhanced error handling for missing Azure OpenAI configuration in development
  • Maintains fallback to global MCP configuration when user-specific config is unavailable

Testing & Validation:

  • ✅ Application builds and runs successfully
  • ✅ MCP configuration page loads and displays correctly
  • ✅ Navigation integration works properly
  • ✅ Error handling for missing configurations
  • ✅ MCP server connection attempts work as expected
  • Parameter replacement logic validated: All test scenarios pass
    • String replacement: "Bearer ${input:api_token}""Bearer sk-test987654321"
    • Dictionary replacement: Environment variables with placeholders ✓
    • List replacement: Command arguments with placeholders ✓
    • Multiple replacements: Multiple placeholders in single string ✓

Architecture Benefits:

  • Per-User Configuration: Each user can configure their own MCP input parameters
  • Secure Storage: Sensitive parameters are encrypted using AES-256 before database storage
  • Dynamic Loading: MCP plugins are loaded per user session with their specific parameters
  • Fallback Support: Gracefully falls back to global MCP configuration when needed
  • Minimal Changes: Implementation preserves existing functionality while adding new capabilities

Current State:

  • Infrastructure is complete and fully functional
  • User-specific MCP configuration is initialized when users load the application
  • MCP input parameters are securely encrypted and stored per user
  • UI provides intuitive configuration management for users
  • System gracefully handles missing configurations and falls back to global settings
  • Parameter replacement functionality is thoroughly tested and validated

This implementation enables users to have personalized MCP server configurations similar to GitHub Copilot and Visual Studio Code, with secure parameter storage and dynamic plugin loading based on user-specific inputs.

Fixes #19.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits July 18, 2025 13:20
Co-authored-by: mhackermsft <61195478+mhackermsft@users.noreply.github.com>
Co-authored-by: mhackermsft <61195478+mhackermsft@users.noreply.github.com>
Co-authored-by: mhackermsft <61195478+mhackermsft@users.noreply.github.com>
@mhackermsft
Copy link
Owner

try again

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.

2 participants