Skip to content

feat(dev-cli): Add MCP Server to dev-cli for AI Assistant Integration and translation tools#259

Closed
JumpLink wants to merge 34 commits into
mainfrom
feat/dev-cli-mcp
Closed

feat(dev-cli): Add MCP Server to dev-cli for AI Assistant Integration and translation tools#259
JumpLink wants to merge 34 commits into
mainfrom
feat/dev-cli-mcp

Conversation

@JumpLink
Copy link
Copy Markdown
Collaborator

@JumpLink JumpLink commented Jun 27, 2025

🎯 Why This PR (Second Attempt)

This PR was previously closed due to scope concerns. I'm reopening it with a clearer focus because I believe this internal tooling represents exactly the kind of AI experimentation we should be doing at Beabee.

Key Arguments:

  • Internal Tool First: This is for developers, not end users - perfect for experimenting with AI integration
  • Foundation for Future: MCP is likely the best path for AI integration in our platform later
  • Immediate Value: Solves real development needs (translation validation during code reviews)
  • Low Risk: Self-contained within dev-cli, doesn't affect production systems

🎥 Demo

I've created a demonstration video showing the translation CLI commands in action:

dev-cli-translations.webm

And a video showing the MCP Server in action:

mcp-translations.webm

🚀 What's Implemented

MCP Server Foundation

  • Exposes dev tools to AI assistants via Model Context Protocol
  • Works with Cursor (auto-configured), Claude Desktop, VS Code, any MCP client
  • Clean separation: CLI for humans, MCP for AI, shared logic

Translation Management Tools

  • check_translation_key - Verify key existence across locales
  • get_translations - Get values for a key across all locales
  • list_translation_keys - Browse available keys with filtering
  • set_translation - Create/update translations across locales
  • validate_translation_usage - Key format validation with suggestions

Automatic Integration

  • Cursor users get instant access via .cursor/mcp.json
  • No setup required - just works in this workspace
  • Universal: works with any MCP-compatible client

🏗️ Architecture Benefits

Smart Design:

  • CLI Commands: Human-friendly with help text and examples
  • MCP Tools: AI-optimized with JSON schemas and structured responses
  • Shared Actions: Both interfaces use the same underlying logic

Why This Approach Works:

  • ✅ Solves immediate need (translation validation for PRs)
  • ✅ Benefits entire team (AI-powered dev tools)
  • ✅ Extensible foundation for future tools
  • ✅ Universal compatibility (not tied to specific AI client)

🔍 Files Changed

Core Implementation:

  • apps/dev-cli/src/actions/mcp/server.ts - MCP server
  • apps/dev-cli/src/actions/translation.ts - Translation logic
  • apps/dev-cli/src/tools/translation.ts - MCP tool definitions
  • apps/dev-cli/src/commands/{mcp,translation}.ts - CLI commands

Integration:

  • .cursor/mcp.json - Automatic Cursor integration
  • Updated README with comprehensive documentation

Dependencies:

  • @modelcontextprotocol/sdk - MCP protocol implementation
  • @beabee/locale - Translation system integration

Testing Completed

  • MCP server starts and registers tools correctly
  • Translation validation works across all locales
  • Translation creation/updates work properly
  • Cursor integration works automatically
  • CLI commands work for manual use

This represents our first step into AI tooling - internal, low-risk, high-value experimentation that builds toward future platform integration.

- Add MCP server as CLI command (`yarn dev-cli mcp`)
- Implement modular MCP tools registry structure
- Add MCP types and interfaces for extensibility
- Integrate MCP server action into existing CLI architecture
- Add MCP SDK dependency (^1.13.2)
- Prepare foundation for implementing specific MCP tools

The architecture follows separation of concerns:
- CLI commands remain unchanged using yargs
- MCP server uses native MCP SDK
- Both share the same underlying actions layer
- Tools can be implemented in separate files for maintainability

Usage:
  yarn dev-cli mcp          # Start MCP server
  yarn dev-cli mcp --debug  # Start with debug logging
@JumpLink JumpLink changed the title [WIP] feat(dev-cli): Add MCP (Model Context Protocol) server integration feat(dev-cli): Add MCP (Model Context Protocol) server integration Jun 27, 2025
@JumpLink JumpLink changed the title feat(dev-cli): Add MCP (Model Context Protocol) server integration feat(dev-cli): Add MCP (Model Context Protocol) server with translation key validation Jun 27, 2025
JumpLink added 10 commits June 27, 2025 12:43
… rules

- Introduced a new document outlining core commit practices, consistency strategies, and quality standards for git commits.
- Updated migration rules for Vue components to reference the new commit best practices document.
- Clarified i18n dependencies handling in migration rules and enhanced completion steps for better clarity.
- Add @beabee/locale dependency for translation key validation
- Create comprehensive translation actions with locale support:
  * checkTranslationKey() - validates key existence across locales
  * getTranslations() - retrieves translation values for keys
  * listTranslationKeys() - lists available keys with filtering
  * validateTranslationUsage() - validates key format with suggestions
  * getAvailableLocales() - returns all supported locales

- Implement CLI commands for translation management:
  * translation check-key <key> - check key existence
  * translation get <key> - get translations for a key
  * translation list - list available keys with prefix filtering
  * translation validate <key> - validate key format
  * translation locales - list available locales

- Create MCP server with translation tools for AI assistants:
  * check_translation_key - MCP tool for key validation
  * get_translations - MCP tool for translation retrieval
  * list_translation_keys - MCP tool for key listing
  * validate_translation_usage - MCP tool for key validation
  * get_available_locales - MCP tool for locale information

- Improve code structure following cursor rules:
  * Move types to src/types/ directory
  * Separate interfaces into dedicated files
  * Use ESM imports and proper TypeScript patterns
  * Add comprehensive documentation

- Fix MCP server startup issue by removing version alias conflict
- Use require() workaround for JSON locale imports compatibility

The implementation provides both CLI and MCP interfaces for translation
key validation, enabling developers and AI assistants to work with
translation files effectively.
…d utilities

- Added a new guideline to always store types and interfaces in `src/types/` and utility methods in `src/utils/`.
- This change enhances code organization and maintainability by promoting a clear structure for type and utility management.
- Moved MCP tools to a dedicated `src/tools/` directory for better organization.
- Introduced new translation tools for checking keys, retrieving translations, listing keys, and validating usage.
- Updated MCP server to utilize the new package structure and fetch version information from a centralized `package.ts` utility.
- Removed obsolete tools and streamlined the MCP server's tool integration.
…apper

- Changed the CLI entry point in package.json from a TypeScript file to a new JavaScript wrapper.
- Introduced a new dev-cli.js file that allows execution of TypeScript code with necessary Node.js parameters.
- The wrapper supports experimental features for seamless TypeScript execution without a compilation step.
…ctory

- Modified the path resolution for reading package.json to use the dynamic directory of the current module.
- This change ensures that the correct package.json file is accessed regardless of the execution context.
- Added @beabee/locale dependency for improved translation key management.
- Updated README.md to include detailed documentation for new translation commands: `locales`, `check-key`, `get`, `list-keys`, and `validate`.
- Introduced a new configuration file `.cursor/mcp.json` for MCP server setup, enabling AI assistants to access translation tools directly.
- Changed CLI entry point from TypeScript to a JavaScript wrapper for better execution handling.
- Updated yarn.lock to reflect the new dependency.
@JumpLink JumpLink marked this pull request as ready for review June 27, 2025 15:30
@JumpLink JumpLink requested a review from wpf500 June 30, 2025 07:46
JumpLink added 11 commits July 1, 2025 07:28
…on protocols

- Updated migration strategy to include critical AI agent instructions for validating translation keys using MCP tools.
- Added detailed prerequisites and a validation protocol to ensure all translation keys are checked before implementation.
- Emphasized the importance of documenting key mappings and verifying dependencies during the migration process.
- Included error recovery steps for handling validation failures.

This commit improves the robustness of the vue-i18n integration by ensuring proper validation and documentation practices are followed.
- Added TypeScript source exports to @beabee/locale package enabling direct imports via /src path
- Updated dev-cli to use direct TypeScript imports, eliminating need for locale package rebuilds
- Enhanced esbuild configuration with TypeScript transformation support
- Updated Node.js execution flags across toolchain to support --experimental-transform-types

This change enables dev-cli to access locale data directly from TypeScript sources,
significantly improving developer experience by removing build dependencies.
Foundation for future CLI and MCP-based locale modification capabilities.
…tools

- Added setTranslation function to enable writing translation values to locale JSON files
- Introduced new CLI command `translation set` for updating translations across multiple locales
- Created new MCP tool `set_translation` for AI assistant integration
- Enhanced translation types with SetTranslationOptions and SetTranslationResult interfaces
- Added support for nested key creation and validation during translation updates
- Updated README documentation with comprehensive examples for translation setting

This enables developers and AI assistants to directly modify translation files
through both CLI commands and MCP protocol, supporting automated localization workflows.
…ionality

- Added `restart_server` MCP tool to allow automatic server restarts when new tools are added
- Introduced `list_tools` MCP tool for listing all available tools and their descriptions
- Created new server.ts module for server management functionality
- Updated documentation with server management guidelines and usage examples

This addresses the issue where the MCP server needs manual restart after adding new tools,
enabling AI assistants to automatically restart the server when needed.
- Removed custom list_tools implementation as it duplicates built-in MCP protocol functionality
- Updated documentation to clarify that tool listing is natively supported by MCP
- MCP protocol provides ListToolsRequestSchema for automatic tool discovery by AI assistants

The MCP protocol already includes tool listing capabilities, making the custom implementation unnecessary.
…ading

- Removed global require() import of locale files that were cached at startup
- Replaced all locales[locale] usages with await readLocaleFile(locale) calls
- Translation functions now read locale files dynamically from disk on each call
- Enables immediate availability of new translations without server restart

This ensures that newly added translations via set_translation are immediately
accessible through get_translations and other tools without requiring MCP server restart.
…ant code

- Use require.resolve() instead of manual relative path for more robust locale directory discovery
- Remove redundant .replace('@', '@') from getLocaleFileName function
- Simplify locale filename generation to just `${locale}.json`
- Remove unused fileURLToPath imports

This makes the locale file resolution more resilient to directory structure changes
and eliminates pointless string replacement operations.
- Deleted server.ts containing restart_server tool that causes connection issues with Cursor
- Removed server management tools documentation and exports
- Updated README to emphasize immediate availability of new translations via dynamic loading

Since translations are now loaded dynamically with readLocaleFile(), new translations
are immediately available without requiring server restart, making the restart tool obsolete.
@JumpLink JumpLink changed the base branch from main to refactor/locale July 4, 2025 05:38
JumpLink added 2 commits July 4, 2025 12:09
…refactoring

- Removed zod dependency from package.json and yarn.lock.
- Updated translation.ts to use more specific types for translation data, improving type safety.
- Added detailed error handling in getNestedValue functions to provide better debugging information.
- Adjusted getAllKeysFromObject to only return valid translation keys (string values).
@JumpLink JumpLink reopened this Aug 6, 2025
@JumpLink JumpLink changed the base branch from refactor/locale to main August 6, 2025 06:09
@JumpLink JumpLink marked this pull request as draft August 6, 2025 06:09
@JumpLink JumpLink removed the request for review from wpf500 August 6, 2025 06:16
@JumpLink JumpLink changed the title feat(dev-cli): Add MCP (Model Context Protocol) server with translation key validation feat(dev-cli): Add MCP server with translation key validation Aug 6, 2025
- Empty strings in locale files are now correctly treated as missing translations
- Updated getNestedValueDetailed to distinguish between empty strings and wrong types  
- Improved error messages: "contains empty string (treated as missing)" instead of confusing "contains string instead of string"
- Updated getAllKeysFromObject to exclude keys with empty string values
- Enhanced setTranslation to skip empty/whitespace-only values consistently
Empty strings are now expected behavior and don't need debug warnings.
Only log actual type mismatches for debugging purposes.
@JumpLink JumpLink changed the title feat(dev-cli): Add MCP server with translation key validation Add MCP Server to dev-cli for AI Assistant Integration Aug 6, 2025
@JumpLink JumpLink changed the title Add MCP Server to dev-cli for AI Assistant Integration feat(dev-cli): Add MCP Server to dev-cli for AI Assistant Integration and translation tools Aug 6, 2025
@JumpLink JumpLink marked this pull request as ready for review August 8, 2025 05:02
@JumpLink JumpLink marked this pull request as draft August 27, 2025 07:27
JumpLink added 2 commits May 26, 2026 11:56
# Conflicts:
#	apps/dev-cli/README.md
#	apps/dev-cli/package.json
#	apps/dev-cli/src/index.ts
#	yarn.lock
@saschafoerster
Copy link
Copy Markdown

MCP in contact with very personal data. Convince me this is in any circumstance a good idea. Or legal with GDPR in mind. Until then, I do not want any AI touch my customers data at all.

@JumpLink
Copy link
Copy Markdown
Collaborator Author

@saschafoerster This PR is a developer feature that sets up an MCP server for the project’s translation data, so that this data can be maintained using AI during the project’s development. It therefore does not come into contact with the production data, only with the project’s source code.

However, I understand your stance on AI; we also believe that such data should not be sent to such companies and are therefore experimenting internally with open-source AI models that can be hosted either in-house or in Europe. To the best of my knowledge, however, there are currently no concrete plans for Beabee in this regard.

@wpf500
Copy link
Copy Markdown
Member

wpf500 commented Jun 1, 2026

I'm closing this PR as it's very old and the changes will still be available to be used in a future PR if we want to bring in developer-specific MCP functionality.

@wpf500 wpf500 closed this Jun 1, 2026
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