enable_source
Activates a content source to access Swift and SwiftUI best practices. Premium sources require separate setup.
Instructions
Enable a content source (requires setup for premium sources)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source | Yes | Source ID (e.g., 'patreon') |
Implementation Reference
- src/tools/handlers/enableSource.ts:7-34 (handler)The main handler function for the 'enable_source' tool. It validates the 'source' argument, checks if the source exists, verifies configuration for premium sources, and calls sourceManager.enableSource() to enable it.
export const enableSourceHandler: ToolHandler = async (args, context) => { const sourceId = validateRequiredString(args, 'source', 'Usage: enable_source({ source: "patreon" })'); if (isValidationError(sourceId)) return sourceId; const source = context.sourceManager.getSource(sourceId); if (!source) { return createErrorResponse(`Unknown source: "${sourceId}" Available sources: ${context.sourceManager.getAllSources().map(s => `- ${s.id}: ${s.name}`).join('\n')}`); } if (source.requiresAuth && !context.sourceManager.isSourceConfigured(sourceId)) { return createTextResponse(`⚙️ ${source.name} requires setup first. Run: swift-patterns-mcp ${sourceId} setup This will guide you through: ${sourceId === 'patreon' ? '- Patreon OAuth authentication\n- Connecting your subscriptions' : '- Authentication setup'}`); } context.sourceManager.enableSource(sourceId); return createTextResponse(`✅ ${source.name} enabled! You can now use patterns from this source.`); }; - src/tools/registration.ts:58-71 (schema)The tool registration metadata including name, description, and JSON Schema input schema for 'enable_source'.
{ name: "enable_source", description: "Enable a content source (requires setup for premium sources)", inputSchema: { type: "object", properties: { source: { type: "string", description: "Source ID (e.g., 'patreon')", }, }, required: ["source"], }, }, - src/tools/index.ts:18-18 (registration)Registration of the 'enable_source' tool name to the enableSourceHandler via registerHandler.
registerHandler('enable_source', enableSourceHandler); - src/config/sources.ts:192-211 (helper)The SourceManager.enableSource() method that actually persists the enabled state for a source ID, modifying the config and saving it.
enableSource(id: string): boolean { const source = this.getSource(id); if (!source) return false; // Check if requires configuration if (source.requiresAuth && !this.isSourceConfigured(id)) { throw new Error( `Source "${source.name}" requires configuration. Run: swift-patterns-mcp ${id} setup` ); } if (!this.config.sources[id]) { this.config.sources[id] = { enabled: true, configured: !source.requiresAuth }; } else { this.config.sources[id].enabled = true; } this.saveConfig(); return true; } - Mock implementation of enableSource used in test fixtures.
enableSource: vi.fn(),