Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8069993
Implement MCP client integration with proper handshake
smkohnstamm Sep 22, 2025
6b2228c
feat: Integrate remote MCP server with SSE support
smkohnstamm Sep 23, 2025
19a35ce
feat: implement JWT token enhancement for MCP authentication
smkohnstamm Sep 24, 2025
395d2d3
fix: Resolve critical TypeScript compilation errors
smkohnstamm Sep 24, 2025
2b4a880
fix: Resolve critical compilation errors
smkohnstamm Sep 24, 2025
cd9a02d
fix: Resolve bearer token retrieval issue
smkohnstamm Sep 24, 2025
9ea2dd5
debug: Add debugging to EnhancedTokenGenerator config access
smkohnstamm Sep 24, 2025
0ce689b
debug: Add comprehensive config loading debugging
smkohnstamm Sep 24, 2025
bad8cf8
fix: Use DynamicAuthManager for enhanced token generation
smkohnstamm Sep 24, 2025
081a1d7
debug: Add comprehensive role extraction debugging
smkohnstamm Sep 24, 2025
b02bb85
debug: Add detailed role extraction debugging
smkohnstamm Sep 24, 2025
16f044e
fix: Pass role information from MCPContextProvider to DynamicAuthManager
smkohnstamm Sep 24, 2025
5261e44
fix: Move role information logic inside useMCPContextState
smkohnstamm Sep 24, 2025
0539977
fix: Force token regeneration when role information changes
smkohnstamm Sep 24, 2025
0c63d52
feat: Add MCP Server Debug Test component
smkohnstamm Sep 24, 2025
3f95624
fix: Resolve compilation errors in MCPServerDebugTest
smkohnstamm Sep 24, 2025
c19e6f6
docs: Add comprehensive MCP server implementation guide
smkohnstamm Sep 24, 2025
7d50cc9
Normalize bucket handoff and document enhanced JWT payload
smkohnstamm Sep 24, 2025
3c5d5b5
Add comprehensive MCP integration documentation
smkohnstamm Sep 24, 2025
0458381
feat: Update MCP client v2 with enhanced OAuth and server configurations
smkohnstamm Sep 26, 2025
db0049f
feat: improve text entry bar tools
smkohnstamm Oct 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
540 changes: 540 additions & 0 deletions catalog/app/components/Assistant/MCP/AuthTest.tsx

Large diffs are not rendered by default.

119 changes: 119 additions & 0 deletions catalog/app/components/Assistant/MCP/BedrockIntegration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/**
* Bedrock Integration for MCP Client
*
* This file provides integration between the MCP Client and Amazon Bedrock
* for AI-powered data management operations.
*/

import type { MCPClient, MCPTool } from './types'

export interface BedrockMCPRequest {
prompt: string
context?: string
}

export interface BedrockMCPResponse {
content: string
toolCalls?: Array<{
toolId: string
args: Record<string, any>
}>
}

export interface BedrockMCPConfig {
modelId: string
region: string
accessKeyId?: string
secretAccessKey?: string
}

export class BedrockMCPIntegration {
private config: BedrockMCPConfig
private mcpClient: MCPClient

constructor(config: BedrockMCPConfig, mcpClient: MCPClient) {
this.config = config
this.mcpClient = mcpClient
}

/**
* Process a conversation with MCP tools using Bedrock
*/
async processWithMCPTools(request: BedrockMCPRequest): Promise<BedrockMCPResponse> {
try {
// Get available tools from MCP client
const tools = await this.mcpClient.listAvailableTools()

// Format tools for Bedrock
const formattedTools = tools.map((tool: MCPTool) => ({
name: tool.name,
description: tool.description,
inputSchema: tool.inputSchema,
}))

// Create the prompt with tool information
const systemPrompt = `You are an AI assistant with access to Quilt data management tools.
Available tools:
${formattedTools.map((tool: any) => `- ${tool.name}: ${tool.description}`).join('\n')}

When you need to use a tool, respond with a JSON object containing:
{
"tool_calls": [
{
"tool_id": "tool-name",
"args": { "param": "value" }
}
]
}

Otherwise, respond normally with helpful information.`

const fullPrompt = `${systemPrompt}\n\nUser: ${request.prompt}`

// For now, return a mock response that demonstrates tool usage
// In a real implementation, this would call AWS Bedrock
const response: BedrockMCPResponse = {
content: `I can help you with Quilt data management using these tools: ${formattedTools.map((t: any) => t.name).join(', ')}.

What would you like to do? I can:
- Search for packages
- Create new packages
- Update package metadata
- Create visualizations`,
toolCalls: [],
}

Comment on lines +72 to +85
Copy link
Contributor

Choose a reason for hiding this comment

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

style: This is currently a mock implementation that returns static response text rather than calling AWS Bedrock. Consider implementing the actual Bedrock client integration or adding clear documentation about the mock status.

return response
} catch (error) {
throw new Error(`Bedrock MCP processing error: ${error}`)
}
}

/**
* Execute tool calls from Bedrock response
*/
async executeToolCalls(
toolCalls: Array<{ toolId: string; args: Record<string, any> }>,
): Promise<any[]> {
try {
const results = []

for (const toolCall of toolCalls) {
const result = await this.mcpClient.callTool({
name: toolCall.toolId,
arguments: toolCall.args,
})
results.push(result)
}

return results
} catch (error) {
throw new Error(`Tool execution error: ${error}`)
}
}
}

// Create a simple layer for the Bedrock MCP Integration
export const createBedrockMCPLayer = (config: BedrockMCPConfig, mcpClient: MCPClient) => {
return new BedrockMCPIntegration(config, mcpClient)
}
157 changes: 157 additions & 0 deletions catalog/app/components/Assistant/MCP/CONFIGURATION_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# Dynamic Authentication Configuration Guide

This guide explains how to configure the dynamic authentication system for the Quilt MCP Server integration.

## Required Configuration

### JWT Signing Configuration

The enhanced JWT token generation requires two configuration values to be set in your deployment:

#### 1. MCP Enhanced JWT Secret (`mcpEnhancedJwtSecret`)

**Required**: A shared secret used to sign enhanced MCP JWT tokens using HS256 algorithm.

**Example**:
```json
{
"mcpEnhancedJwtSecret": "your-super-secret-jwt-signing-key-here-must-be-at-least-32-characters"
}
```

**Security Requirements**:
- Minimum 32 characters
- Use a cryptographically secure random string
- Keep secret and never commit to version control
- Use different secrets for different environments (dev/staging/prod)

**Generation**:
```bash
# Generate a secure random secret (64 characters)
openssl rand -hex 32

# Or using Node.js
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
```

#### 2. MCP Enhanced JWT Key ID (`mcpEnhancedJwtKid`) - Optional

**Optional**: A key identifier attached to enhanced MCP JWT signatures for key rotation support.

**Example**:
```json
{
"mcpEnhancedJwtKid": "quilt-mcp-v1"
}
```

## Environment-Specific Configuration

### Development Environment

For local development, you can set these values in your local configuration:

```javascript
// In your local config file
{
"mcpEnhancedJwtSecret": "dev-secret-key-for-local-development-only",
"mcpEnhancedJwtKid": "dev-v1"
}
```

### Production Environment

For production deployments, these values should be:

1. **Generated securely** using cryptographically secure random generators
2. **Stored securely** in your deployment configuration (e.g., AWS Secrets Manager, Kubernetes secrets)
3. **Rotated regularly** for security best practices
4. **Shared with MCP server** so it can validate the tokens

## MCP Server Configuration

The MCP server must be configured with the same JWT secret to validate the enhanced tokens:

```yaml
# MCP Server Configuration
jwt:
secret: "your-super-secret-jwt-signing-key-here-must-be-at-least-32-characters"
keyId: "quilt-mcp-v1" # Optional, must match if provided
algorithm: "HS256"
```

## Configuration Validation

The system will automatically validate the configuration:

- βœ… **JWT Secret Present**: Enhanced token generation enabled
- ❌ **JWT Secret Missing**: Falls back to original unsigned token
- ⚠️ **JWT Secret Too Short**: Warning logged, may cause validation failures

## Testing Configuration

Use the Integration Test component in the Qurator DevTools to validate your configuration:

1. Open Qurator Assistant
2. Go to DevTools section
3. Run "Integration Test Suite"
4. Check "Enhanced JWT Token Generation" tests

## Troubleshooting

### Common Issues

#### 1. "Enhanced token is identical to original token"

**Cause**: JWT secret not configured or too short
**Solution**: Set `mcpEnhancedJwtSecret` in your configuration

#### 2. "MCP server rejects enhanced tokens"

**Cause**: MCP server not configured with matching JWT secret
**Solution**: Configure MCP server with the same `mcpEnhancedJwtSecret`

#### 3. "Token validation fails"

**Cause**: Key ID mismatch between frontend and MCP server
**Solution**: Ensure `mcpEnhancedJwtKid` matches on both sides, or remove it entirely

### Debug Information

Enable debug logging to troubleshoot JWT issues:

```javascript
// In browser console
localStorage.setItem('debug', 'quilt:mcp:jwt')
```

This will show detailed JWT generation and validation logs.

## Security Best Practices

1. **Never commit secrets to version control**
2. **Use different secrets for each environment**
3. **Rotate secrets regularly** (recommended: every 90 days)
4. **Monitor for unauthorized token usage**
5. **Use strong, random secrets** (minimum 32 characters)
6. **Store secrets securely** (use proper secret management)

## Example Complete Configuration

```json
{
"mcpEndpoint": "https://your-mcp-server.com/mcp",
"mcpEnhancedJwtSecret": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6",
"mcpEnhancedJwtKid": "quilt-mcp-v1",
"qurator": true
}
```

## Support

If you encounter issues with the configuration:

1. Check the browser console for error messages
2. Run the Integration Test Suite
3. Verify MCP server configuration matches frontend
4. Contact the development team with specific error details
Loading
Loading