feat(dev-cli): Add MCP Server to dev-cli for AI Assistant Integration and translation tools#259
feat(dev-cli): Add MCP Server to dev-cli for AI Assistant Integration and translation tools#259JumpLink wants to merge 34 commits into
Conversation
- 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
… 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.
…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.
…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).
- 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.
# Conflicts: # apps/dev-cli/README.md # apps/dev-cli/package.json # apps/dev-cli/src/index.ts # yarn.lock
# Conflicts: # yarn.lock
|
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. |
|
@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. |
|
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. |
🎯 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:
🎥 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
Translation Management Tools
check_translation_key- Verify key existence across localesget_translations- Get values for a key across all localeslist_translation_keys- Browse available keys with filteringset_translation- Create/update translations across localesvalidate_translation_usage- Key format validation with suggestionsAutomatic Integration
.cursor/mcp.json🏗️ Architecture Benefits
Smart Design:
Why This Approach Works:
🔍 Files Changed
Core Implementation:
apps/dev-cli/src/actions/mcp/server.ts- MCP serverapps/dev-cli/src/actions/translation.ts- Translation logicapps/dev-cli/src/tools/translation.ts- MCP tool definitionsapps/dev-cli/src/commands/{mcp,translation}.ts- CLI commandsIntegration:
.cursor/mcp.json- Automatic Cursor integrationDependencies:
@modelcontextprotocol/sdk- MCP protocol implementation@beabee/locale- Translation system integration✅ Testing Completed
This represents our first step into AI tooling - internal, low-risk, high-value experimentation that builds toward future platform integration.