Skip to content

Conversation

@jonathannorris
Copy link
Member

@jonathannorris jonathannorris commented Jul 23, 2025

Summary

This PR introduces Model Context Protocol (MCP) server support to the DevCycle CLI, enabling AI coding assistants like Cursor and Claude to interact directly with DevCycle's feature flag management system.

What's Changed

New Features

  • MCP Server Implementation: Added a complete MCP server that exposes DevCycle functionality through standardized tools
  • Comprehensive Tool Set: Implemented 35+ tools covering:
    • Feature flag management (create, update, delete, list)
    • Variable management
    • Environment and SDK key management
    • Project management
    • Self-targeting and overrides
    • Targeting rules and audience configuration
    • Audit log history

Technical Improvements

  • Enhanced API Client: Updated the API client to support all MCP operations
  • Zod Schema Integration: Added type-safe request/response handling using Zod schemas
  • Request Header Tracking: Added MCP-specific headers for analytics and debugging
  • Error Handling: Comprehensive error handling with detailed validation messages

Documentation & Developer Experience

  • Extensive Documentation: Added 510+ lines of comprehensive MCP documentation
  • Planning Documents: Included architectural planning and abstraction summaries
  • Cursor Rules: Added project-specific rules for API patterns, CLI commands, testing, and UI patterns
  • Dashboard Links: All tool responses include relevant DevCycle dashboard links

Infrastructure Updates

  • Updated to Yarn 4.9.2
  • Added MCP binary scripts for cross-platform support
  • Added @modelcontextprotocol/sdk dependency

Usage

After installation, developers can:

  • Manage feature flags directly from their AI assistant
  • Update targeting rules without leaving the editor
  • Create and modify variables with type safety
  • View audit logs and feature history
  • Set local overrides for testing

Testing

The implementation includes comprehensive validation and error handling to ensure safe operations, with warnings for production environment changes.

kaushalkapasi and others added 30 commits September 5, 2023 15:23
…#276)

* DVC-8635 [feat]: add CLI command to clear all overrides for a project

* DVC-8635 [chore]: update output to better reflect output success, warning or failure

* DVC-8635 [fix]: update identity update & overrides clear commands to respect headless flag
…rompt manually in create command (#281)

* chore: remove variable feature prompt from create variable prompts, prompt manually in create command

* chore: added test for attaching feature to variable
override get command logic for when a feature and environment are specified
jonathannorris and others added 2 commits August 1, 2025 09:40
* Update Create Feature description to make creating a new feature easier

* another update

* more description tweaks

* chore: update create_feature description

* chore: update description again

---------

Co-authored-by: Jonathan Norris <jonathan@taplytics.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Aug 1, 2025

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
devcycle-mcp-server aa9d14c Aug 11 2025, 09:28 PM

@jonathannorris jonathannorris requested a review from Copilot August 5, 2025 18:10

This comment was marked as outdated.

jonathannorris and others added 10 commits August 5, 2025 14:29
Making sure create feature names all targeting rules it creates
* fix: replace z.array(z.any()) with z.array(z.unknown()) for MCP schema compatibility

* test: add MCP schema validation tests to prevent array items issues

* fix: types in tests
…tions (#486)

* refactor(mcp): unify header setting between CLI and Worker implementations

* chore: cleanup TS worker config

* feat: add destructiveHint to self-targeting tools

* fix: env.ENABLE_OUTPUT_SCHEMAS support

* chore: cleanup setting mcp headers

* chore: cleanup
@jonathannorris jonathannorris requested a review from Copilot August 11, 2025 21:02
Copy link

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 introduces comprehensive Model Context Protocol (MCP) server support to the DevCycle CLI, enabling AI coding assistants like Cursor and Claude to directly interact with DevCycle's feature flag management system through standardized tools.

Key Changes:

  • Complete MCP server implementation with 35+ tools for feature flag, variable, environment, and project management
  • Enhanced API client with Zod schema integration and comprehensive error handling
  • Cloudflare Worker deployment for hosted MCP service accessible via OAuth

Reviewed Changes

Copilot reviewed 52 out of 310 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/mcp/tools/*.ts Individual tool implementations for features, projects, environments, variables, results, and self-targeting
src/mcp/server.ts Core MCP server implementation with tool registration and error handling
src/mcp/index.ts Main entry point for standalone MCP server execution
src/api/*.ts Enhanced API functions with additional parameters and new endpoints
mcp-worker/src/*.ts Cloudflare Worker implementation with OAuth authentication
package.json Added MCP SDK dependency and updated to Yarn 4.9.2

'listProjects',
args,
async (authToken: string) => {
console.log('listProjectsHandler args: ', args)
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

Debug console.log statements should be removed in production code. Consider using a proper logging framework or removing this debug statement.

Suggested change
console.log('listProjectsHandler args: ', args)

Copilot uses AI. Check for mistakes.
import { makeApi, Zodios, type ZodiosOptions } from '@zodios/core'
import { z } from 'zod'

/**
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

Excellent documentation about MCP schema compatibility. This is a critical implementation detail that prevents runtime issues with the MCP protocol.

Copilot uses AI. Check for mistakes.
JSON.parse(referrerMetadata)
isCallerCli = parsedDvcReferrerMetadata.caller === 'cli'
}
} catch (parseError) {
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

Good defensive programming - the error handling for JSON parsing prevents crashes when referrer metadata is malformed.

Copilot uses AI. Check for mistakes.
Comment on lines 2 to 6
# Replace these with your actual Auth0 values from https://manage.auth0.com/

AUTH0_CLIENT_ID=NpnZJH8kJ6ZrU4tDPGVMunJA6cHMt0At
AUTH0_CLIENT_SECRET=ToEcJrTJjYsVgCSTWbjJ1mRVslcf5G7VuiLiCxRS77VkqAJAhkm_Qz0ipoDnWeZf

Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

Development credentials are exposed in the repository. While these appear to be development/test credentials, consider using placeholder values in the committed file and document how to obtain actual credentials.

Suggested change
# Replace these with your actual Auth0 values from https://manage.auth0.com/
AUTH0_CLIENT_ID=NpnZJH8kJ6ZrU4tDPGVMunJA6cHMt0At
AUTH0_CLIENT_SECRET=ToEcJrTJjYsVgCSTWbjJ1mRVslcf5G7VuiLiCxRS77VkqAJAhkm_Qz0ipoDnWeZf
# Replace the placeholder values below with your actual Auth0 credentials from https://manage.auth0.com/
# DO NOT commit real credentials to the repository.
AUTH0_CLIENT_ID=YOUR_AUTH0_CLIENT_ID
AUTH0_CLIENT_SECRET=YOUR_AUTH0_CLIENT_SECRET

Copilot uses AI. Check for mistakes.
# Replace these with your actual Auth0 values from https://manage.auth0.com/

AUTH0_CLIENT_ID=NpnZJH8kJ6ZrU4tDPGVMunJA6cHMt0At
AUTH0_CLIENT_SECRET=ToEcJrTJjYsVgCSTWbjJ1mRVslcf5G7VuiLiCxRS77VkqAJAhkm_Qz0ipoDnWeZf
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

Development credentials are exposed in the repository. Client secrets should never be committed to version control, even for development environments.

Suggested change
AUTH0_CLIENT_SECRET=ToEcJrTJjYsVgCSTWbjJ1mRVslcf5G7VuiLiCxRS77VkqAJAhkm_Qz0ipoDnWeZf
# Set your Auth0 client secret here for local development. Do NOT commit real secrets to version control.
AUTH0_CLIENT_SECRET=YOUR_AUTH0_CLIENT_SECRET_HERE

Copilot uses AI. Check for mistakes.
async (authToken: string, projectKey: string | undefined) => {
if (!projectKey) {
throw new Error(
'Project key is required for this operation. Please selecting a project first.',
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

Typo in error message: 'selecting' should be 'select'. Should read 'Please select a project first.'

Suggested change
'Project key is required for this operation. Please selecting a project first.',
'Project key is required for this operation. Please select a project first.',

Copilot uses AI. Check for mistakes.
jonathannorris added a commit that referenced this pull request Aug 13, 2025
* feat: add MCP server, recover code from #467

* feat: add all new code

* fix: getCurrentProject handler and refactor project formatting to use common utilities

* docs: add cursor rules for project guidelines

* feat: add local MCP project selection and consolidate utilities

- Add project selection tool for local MCP (localProjectTools.ts)
- Extract shared config management utility (configManager.ts)
- Consolidate dashboard link generation (dashboardLinks.ts)
- Update all MCP tools to use centralized dashboard links
- Enhance DevCycleAuth with project persistence methods

* docs: streamline mcp-worker README for clarity and conciseness

* docs: update mcp.md to reflect current implementation and remove disabled tools

* chore: clean up auth logging

* refactor: use centralized dashboard links in project selection tools

* feat: add root route redirect to MCP documentation

* refactor: update description formatting and fix import paths in mcp tools

* fix: preserve writer headless setting in ConfigManager constructor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.