Closed
Conversation
Introduces the McpCommand for running a local MCP server and outputting client configuration for AI tool integration. Registers the new command in AbpCliCoreModule.
Introduces a new MCP server mode to the ABP CLI, including a JSON-RPC server implementation, health checks, and configuration output. Adds supporting services for HTTP communication and configuration models, and updates the CLI to suppress the banner for MCP commands to avoid corrupting the JSON-RPC stream.
Introduces McpToolDefinition model and McpToolsCacheService to fetch and cache tool definitions from the server, with fallback to cache if the server is unavailable. Updates McpServerService to dynamically register tools based on cached or fetched definitions, and adds related constants and paths. This enables more flexible and up-to-date tool management in the MCP server.
Introduces McpToolDefinitionValidator to validate and filter tool definitions before caching. Updates McpHttpClientService to support configurable MCP server URLs and sanitizes error messages. Enhances McpToolsCacheService to use validated tools, adds restrictive file permissions for cache, and improves error handling and logging. Updates CliConsts with new constants for MCP server configuration.
Enhanced error handling and user messaging in MCP HTTP client and server services, providing sanitized and user-friendly error responses for network, timeout, and unexpected errors. Updated MCP command to enforce license validation before tool execution. Improved cross-platform file permission handling in the tools cache service.
Added IMcpLogger interface and McpLogger implementation to provide structured logging for MCP operations, supporting log levels and file rotation. Replaced direct Console.Error logging with IMcpLogger in MCP-related services and commands. Log level is now configurable via the ABP_MCP_LOG_LEVEL environment variable, and logs are written to both file and stderr as appropriate.
Extracted license validation logic in McpCommand to a dedicated method for reuse and clarity. Improved executable path resolution by splitting logic into helper methods. In McpHttpClientService, centralized HTTP exception handling and replaced repeated code with a single method. Refactored tool invocation in McpServerService to use a dedicated handler, improving error handling and logging. Simplified log level parsing in McpLogger for better maintainability.
Updated the command option and help text from 'getconfig' to 'get-config' for consistency and improved readability.
Introduced ITelemetryService to McpCommand and added activity tracking using ActivityNameConsts.AbpCliCommandsMcp. Also updated ActivityNameConsts to include the new activity name constant for MCP command telemetry.
Replaced hardcoded TestServerUrl with awaitable GetMcpServerUrlAsync() in CallToolAsync, CheckServerHealthAsync, and GetToolDefinitionsAsync methods to ensure the correct server URL is used dynamically.
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request adds MCP (Model Context Protocol) server functionality to the ABP CLI, enabling AI tools to interact with ABP.IO services through a standardized protocol. The feature introduces a new abp mcp command that runs a local stdio MCP server, which acts as a bridge between MCP clients (like AI assistants) and the ABP.IO backend.
Key changes:
- New
abp mcpcommand with two modes: server mode (default) and config output mode (get-config) - HTTP client service with caching, validation, and fallback mechanisms for fetching tool definitions from ABP.IO MCP server
- Local MCP server implementation using the ModelContextProtocol library that dynamically registers tools from the backend
- Custom logging system (file + stderr) to avoid corrupting the stdio JSON-RPC communication stream
Reviewed changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| framework/src/Volo.Abp.Core/Volo/Abp/Internal/Telemetry/Constants/ActivityNameConsts.cs | Added telemetry constant for MCP command tracking |
| framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/McpToolsCacheService.cs | Implements 24-hour caching of tool definitions with fallback support |
| framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/McpToolDefinitionValidator.cs | Validates tool definitions from server (names, schemas, properties) |
| framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/McpServerService.cs | Core MCP server that registers and executes tools via stdio transport |
| framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/McpLogger.cs | File and stderr logging to avoid stdout corruption |
| framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/McpHttpClientService.cs | HTTP client for communicating with ABP.IO MCP server |
| framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/IMcpLogger.cs | Logger interface for MCP operations |
| framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Models/McpToolDefinition.cs | Model classes for tool definitions, schemas, and properties |
| framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Models/McpClientConfiguration.cs | Model for MCP client configuration JSON output |
| framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/McpCommand.cs | Main command implementation with license validation and server lifecycle |
| framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/HelpCommand.cs | Modified to silently skip MCP command to avoid stdout corruption |
| framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/CommandSelector.cs | Updated to handle MCP command specially |
| framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs | Modified to suppress banner and version check for MCP command |
| framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliPaths.cs | Added paths for MCP cache and log files |
| framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliConsts.cs | Added MCP-related constants (URLs, environment variables, memory keys) |
| framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs | Registered MCP command in CLI options |
| framework/src/Volo.Abp.Cli.Core/Volo.Abp.Cli.Core.csproj | Added ModelContextProtocol package reference |
| Directory.Packages.props | Added ModelContextProtocol 0.5.0-preview.1 package version |
| .gitignore | Added framework/.cursor to gitignore |
framework/src/Volo.Abp.Core/Volo/Abp/Internal/Telemetry/Constants/ActivityNameConsts.cs
Outdated
Show resolved
Hide resolved
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/McpServerService.cs
Outdated
Show resolved
Hide resolved
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/McpServerService.cs
Outdated
Show resolved
Hide resolved
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/McpHttpClientService.cs
Outdated
Show resolved
Hide resolved
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/McpHttpClientService.cs
Show resolved
Hide resolved
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/McpHttpClientService.cs
Outdated
Show resolved
Hide resolved
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Models/McpToolDefinition.cs
Show resolved
Hide resolved
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/McpHttpClientService.cs
Outdated
Show resolved
Hide resolved
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/McpToolsCacheService.cs
Outdated
Show resolved
Hide resolved
Extracted AbpMcpServerTool to its own file and improved tool name validation in McpHttpClientService. Enhanced error handling and logging, made cache validity configurable, and fixed typos in ActivityNameConsts for AbpCli command telemetry constants.
Deleted the hardcoded TestServerUrl constant from McpHttpClientService as it is no longer needed after testing.
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/McpToolsCacheService.cs
Show resolved
Hide resolved
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/McpToolDefinitionValidator.cs
Outdated
Show resolved
Hide resolved
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/McpHttpClientService.cs
Show resolved
Hide resolved
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/McpCommand.cs
Outdated
Show resolved
Hide resolved
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/McpToolDefinitionValidator.cs
Outdated
Show resolved
Hide resolved
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/McpHttpClientService.cs
Show resolved
Hide resolved
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/McpLogger.cs
Outdated
Show resolved
Hide resolved
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/McpServerService.cs
Show resolved
Hide resolved
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/McpToolsCacheService.cs
Show resolved
Hide resolved
ebicoglu
approved these changes
Jan 13, 2026
Introduces CommandLineArgsExtensions for MCP command detection, removes McpToolDefinitionValidator, and updates MCP tool definition fetching to require a successful server connection. Cleans up unused environment variables, adds mcp-config.json support, and simplifies tool validation and caching logic. These changes improve reliability and maintainability of MCP command execution and tool management.
Replaces the hardcoded localhost URL with the cached server URL in GetMcpServerUrlAsync, enabling dynamic server address resolution.
Refactored McpLogger to use ILogger and Serilog for file logging, removing manual file handling and rotation. Enhanced debug logging in McpHttpClientService and added explicit tool name initialization from cache. Updated Program.cs to use a separate log file for MCP mode. Improved error logging in McpServerService for tool execution failures.
Introduces an optional OutputSchema property to McpToolDefinition and updates AbpMcpServerTool and McpServerService to handle and register tools with output schemas. This enables tools to define and expose their output schema alongside input schema for improved contract clarity.
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Main issue vs-internal issue 7864
Related to vs-internal PR 7820
This PR is dependent on the related vs-internal PR I mentioned above. In order to test and release this feature, other PR need to be tested and released first.
abp mcpcommand addedChecklist