mcp_server_dart 1.2.0 copy "mcp_server_dart: ^1.2.0" to clipboard
mcp_server_dart: ^1.2.0 copied to clipboard

A developer-friendly MCP (Model Context Protocol) framework for Dart with annotations and code generation.

1.2.0 #

  • 🎯 @MCPParam Implementation: The @MCPParam annotation is now fully functional! Add rich metadata to your parameters with custom descriptions, examples, type overrides, and required/optional control.
  • πŸ“ Enhanced Parameter Documentation: Generate professional API documentation with meaningful parameter descriptions instead of generic "Parameter parameter" text.
  • πŸ” Parameter Examples: Include examples in your JSON schemas to help API consumers understand expected values.
  • βš™οΈ Fine-grained Control: Override Dart's type inference and required/optional detection with explicit @MCPParam settings.
  • πŸ”„ Backward Compatible: Existing code without @MCPParam annotations continues to work exactly as before.

What's New #

  • @MCPParam Annotation Processing: The code generator now reads and processes @MCPParam annotations on method parameters
  • Rich JSON Schemas: Generated input schemas include custom descriptions, examples, and type information from @MCPParam
  • Parameter Metadata: Support for description, example, type, and required fields in parameter annotations
  • Type Override Support: Explicitly specify JSON Schema types that differ from Dart types
  • Required/Optional Control: Override Dart's optional parameter detection with explicit required: true/false

Example Usage #

@MCPTool('weather', description: 'Get weather information')
Future<Map<String, dynamic>> getWeather(
  @MCPParam(description: 'City name or coordinates', example: 'San Francisco')
  String location,
  
  @MCPParam(
    required: false,
    description: 'Temperature unit',
    example: 'celsius',
    type: 'string'
  )
  String unit = 'celsius',
) async {
  // Your implementation
}

Generated Schema Enhancement #

Before:

"location": {"type": "string", "description": "Location parameter"}

After:

"location": {
  "type": "string",
  "description": "City name or coordinates", 
  "example": "San Francisco"
}

1.1.2 #

  • ✨ No More @override: Revolutionary extension-based code generation eliminates the need for @override annotations
  • πŸ”§ Resource Generation Fix: Fixed critical issue where generator incorrectly passed uri parameter to resource methods that don't expect it
  • πŸ§ͺ Enhanced Testing: Added comprehensive resource test example demonstrating both URI-based and simple data provider resources
  • πŸ“š Better Resource Patterns: Generator now intelligently detects if resource methods expect URI parameters and handles both patterns correctly
  • πŸ—οΈ Cleaner Architecture: Extension-based registration provides cleaner inheritance and method declarations

What's New #

  • Extension-Based Registration: Generated code now creates extensions on your class instead of abstract base classes
  • No @override Required: Your methods can be declared without @override annotations for cleaner code
  • Automatic Registration: Call registerGeneratedHandlers() in your constructor for seamless setup
  • Cleaner Inheritance: Simply extend MCPServer directly without abstract method constraints

What's Fixed #

  • Resource methods without URI parameters now work correctly (e.g., getServerStats() instead of getServerStats(uri))
  • Generator automatically wraps simple return values in MCPResourceContent for URI-less resources
  • Both traditional URI-based resources and simple data providers are now fully supported
  • Eliminated inheritance complexity with extension-based approach

Example Usage #

// Clean method declarations - no @override needed!
class MyMCPServer extends MCPServer {
  MyMCPServer() : super(name: 'my-server', version: '1.0.0') {
    registerGeneratedHandlers(); // Extension method from generated code
  }

  @MCPTool('greet', description: 'Greet someone')
  Future<String> greet(String name) async {  // No @override!
    return 'Hello, $name!';
  }

  // Traditional resource with URI parameter
  @MCPResource('userProfile')
  Future<MCPResourceContent> getUserProfile(String uri) async { ... }

  // Simple resource without URI parameter (now works!)
  @MCPResource('serverStats') 
  Future<Map<String, dynamic>> getServerStats() async { ... }
}

1.1.1 #

  • πŸ”§ Critical Fix: Resolved build_runner collision between source_gen:combining_builder and mcp_generator
  • πŸ“ File Extension Change: Generated files now use .mcp.dart extension to avoid conflicts with other builders
  • πŸ“š Documentation Update: Updated README and examples to reflect new file extension pattern

Breaking Changes #

  • Generated files now use .mcp.dart extension instead of .g.dart
  • Update your part directives from part 'filename.g.dart'; to part 'filename.mcp.dart';

1.1.0 #

  • πŸš€ Auto-registration: Automatic handler registration using reflection - no need to manually call registerGeneratedHandlers()
  • πŸ”§ Enhanced code generation: Improved MCP generator with better parameter extraction and JSON schema generation
  • πŸ“‹ Smarter annotations: Code generator now uses annotation names instead of method names for tool/resource/prompt registration
  • πŸ₯ Health check: Added ping method support for health monitoring
  • πŸ”„ Protocol upgrade: Updated to MCP protocol version 2025-06-18
  • 🎯 Better validation: Improved input schema generation from method parameters with proper type mapping
  • πŸ“š Enhanced documentation: Generated code includes better descriptions from annotations
  • πŸ› οΈ New examples: Added advanced calculator example with comprehensive tool demonstrations
  • πŸ”— Improved usability: Added stdio() method as alias for start() for better clarity
  • βš™οΈ Configuration updates: Updated MCP config with localhost to 127.0.0.1 for better compatibility
  • 🧹 Code cleanup: Removed excessive comments from generated code for cleaner output

Breaking Changes #

  • Protocol version updated from 2024-11-05 to 2025-06-18
  • Generated handlers now use annotation names instead of method names by default
  • Origin validation now defaults to false instead of true for easier development

1.0.1 #

  • πŸ”§ Fixed origin validation: Resolved production deployment issues with CORS origin checking
  • πŸ—οΈ Modular architecture: Split monolithic server file into focused modules for better maintainability
  • βš™οΈ Configurable origin validation: Added allowLocalhost and validateOrigins parameters for flexible security
  • 🧹 Code organization: Separated concerns into middleware.dart, http_handlers.dart, session_manager.dart, and server_utils.dart
  • πŸ“¦ Package name: Changed from dart_mcp to mcp_server_dart for better pub.flutter-io.cn availability
  • πŸ”’ Enhanced security: Better HTTPS origin support and customizable allowed origins

Breaking Changes #

  • Package name changed from dart_mcp to mcp_server_dart
  • Origin validation now allows HTTPS origins by default (can be disabled with validateOrigins: false)

1.0.0 #

  • πŸš€ Initial release of MCP Dart Framework
  • 🏷️ Annotation-based development: @MCPTool, @MCPResource, @MCPPrompt annotations
  • πŸ”§ Code generation: Automatic boilerplate generation using build_runner
  • πŸ“‘ Multiple transports: Support for stdio, HTTP, and WebSocket connections
  • πŸ” Type-safe: Full Dart type safety with automatic parameter extraction
  • πŸ“š JSON Schema: Automatic input schema generation from method signatures
  • 🌟 Complete example: Google Maps MCP server demonstrating all features
  • πŸ§ͺ Testing support: Built-in support for testing MCP servers
  • πŸ“– Comprehensive docs: Detailed README with examples and API reference

Features #

  • MCPServer base class with full MCP protocol implementation
  • Automatic parameter extraction from method signatures
  • JSON Schema generation for tool input validation
  • WebSocket and stdio transport support
  • Resource and prompt management alongside tools
  • Error handling and logging built-in
  • Type-safe context access for tool parameters

Examples #

  • Simple MCP server example
  • Google Maps MCP server with multiple tools, resources, and prompts
  • Comprehensive test suite demonstrating framework usage
5
likes
150
points
349
downloads

Publisher

verified publishercodenka.com

Weekly Downloads

A developer-friendly MCP (Model Context Protocol) framework for Dart with annotations and code generation.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

analyzer, build, dart_style, json_annotation, json_rpc_2, logging, meta, relic, source_gen

More

Packages that depend on mcp_server_dart