Auto-generated from all feature plans. Last updated: 2026-04-28
- Dart 3.11+ (null-safe)
- MCP (Model Context Protocol) server generation
- Code generation via build_runner and source_gen
- AST analysis using dart:analyzer
packages/
├── easy_api_annotations/ # Annotations package (@Server, @Tool, @Parameter)
│ ├── lib/
│ │ ├── mcp_annotations.dart
│ │ └── stubs.dart
│ ├── example/
│ └── pubspec.yaml
├── easy_api_generator/ # Code generator package
│ ├── lib/
│ │ ├── builder/
│ │ │ ├── mcp_builder.dart # Main builder logic
│ │ │ ├── schema_builder.dart # Schema generation
│ │ │ ├── templates.dart # Code templates (stdio/HTTP/code mode)
│ │ │ ├── openapi_builder.dart # OpenAPI 3.0 spec generation
│ │ │ └── doc_extractor.dart # Doc comment extraction
│ │ └── mcp_generator.dart
│ ├── example/
│ └── pubspec.yaml
example/ # Working example
├── lib/src/
│ ├── user_store.dart
│ ├── todo_store.dart
│ ├── user.dart
│ └── todo.dart
├── bin/
│ ├── example.dart
│ ├── example.mcp.dart # Generated MCP server (do not edit)
│ ├── example.mcp.json # Generated MCP tool metadata
│ └── example.openapi.json # Generated OpenAPI 3.0 spec
└── pubspec.yaml
images/
├── logo-banner.svg
├── logo-icon.svg
└── logo.svg
# Get dependencies
melos bootstrap
# Run code generation
dart run build_runner build
# Run tests
melos run test
# Static analysis
melos run analyze
# Format code
melos run format# Publish annotations package
cd packages/easy_api_annotations && dart pub publish --force
# Publish generator package
cd packages/easy_api_generator && dart pub publish --force- Follow standard Dart conventions
- Use PascalCase for annotation classes:
@Server,@Tool,@Parameter - Use
peek()instead ofread()for optional annotation fields - Always escape backslashes and dollar signs in generated strings
- Add comprehensive DartDoc comments to public APIs
Main server annotation with transport configuration:
transport:McpTransport.stdioorMcpTransport.httpport: HTTP port (default: 3000)address: HTTP bind address (default: '127.0.0.1')generateJson: Generate .mcp.json metadata (default: false)generateMcp: Generate .mcp.dart server (default: true)generateRest: Generate .openapi.json REST spec (default: false)generateCli: Generate .cli.dart command-line app (default: false)codeMode: Enable batch tool orchestration via Node.js sandbox (default: false)codeModeTimeout: Max execution time for code mode scripts in seconds (default: 30)toolPrefix: Prefix all tool names (optional)autoClassPrefix: Prefix tool names with class name (default: false)
Note:
@Mcpis still available as a deprecated typedef for backward compatibility.
Method annotation for exposing functions as MCP tools:
description: Tool description (optional, falls back to doc comments)name: Custom tool name (optional, overrides method name)codeMode: Available in code mode (default: true, set false for destructive ops)icons: Optional icon URLs for visual identification
Parameter annotation for rich metadata:
title,description,example: Documentationminimum,maximum,pattern,enumValues: Validationsensitive: Mark sensitive data (default: false)
Note: @Parameter is optional - generator extracts info from Dart types by default.
.mcp.dart: Complete MCP server implementation (stdio or HTTP).mcp.json: Tool metadata (only ifgenerateJson: true).openapi.json: RESTful OpenAPI 3.0 specification (only ifgenerateRest: true).openapi.dart: REST server implementation (only ifgenerateRest: true).cli.dart: Runnable command-line app exposing tools aspackage:argsCommandRunnersubcommands (only ifgenerateCli: true)
- Update version in pubspec.yaml (both packages together — see "Shared Dependency Strategy")
- Update CHANGELOG.md with new version entry
- Run
melos run deps:check- confirm no stale constraints (especiallyanalyzer) - Run
dart analyze- no issues - Run
melos run pana- target 160/160 on both publishable packages (skipsexample/) - Run
dart pub publish --dry-run- no warnings - Commit changes
- Publish:
dart pub publish --force - Push to GitHub
Both easy_api_annotations and easy_api_generator depend on analyzer and
must stay on compatible major-version ranges. Version drift between the two
will break downstream builds and cause pana's time-bound warnings to fire on
only one package.
Rules of thumb:
- Keep
analyzer(and any other shared transitive dep) constraints identical across bothpackages/*/pubspec.yamlfiles. - When pana reports "constraint does not support the stable version X…", update both packages in the same PR.
- Use
melos run deps:checkto audit outdated shared deps before any release. - Use
melos run deps:upgradeto bump major versions across the workspace. - Use
melos run panato run pana on publishable packages only (never onexample/, which is intentionally non-publishable).
Review cadence: Run melos run deps:check at the start of every feature
branch that touches packages/ and immediately after any pana warning.
- Never expose internal error details in generated code
- Use generic error messages: "An error occurred while processing the request"
- Escape all special characters in generated strings
- Renamed
@Mcpto@Serverand introducedgenerateMcp/generateRestparameters (0.6.0) - Consolidated the 12 per-field
@Serverscan loops into a single AST walk via_extractServerConfig(0.6.0) - Dropped
lib/stubs.dart,lib/builder/doc_extractor.dart,code_builder, andjson_annotationfromeasy_api_generator; droppedanalyzer,stubs.dart, and the deprecatedTool.executionfield fromeasy_api_annotations(0.6.0) - Added Code Mode with Node.js sandbox for batch tool orchestration (0.5.0)
- Added OpenAPI 3.0 specification generation (0.5.0)
- Added rich tool naming: custom names, class prefixes, tool prefixes (0.3.0)
- Added @Parameter annotation for rich parameter metadata (0.2.0)
- Added HTTP transport configuration (port, address)
- Added multi-library tool aggregation
- Made .mcp.json generation optional (generateJson parameter)
- Fixed string escaping for regex patterns and special characters
- Published easy_api_annotations 0.5.0 and easy_api_generator 0.5.0 to pub.dev