mcp_bundle 0.4.14
mcp_bundle: ^0.4.14 copied to clipboard
Bundle schema, loader, validator, expression language, and port contracts providing the foundation for the MCP ecosystem.
// A bundle built from JSON, validated, and written back out. The example
// prints what it found.
// ignore_for_file: avoid_print
import 'package:mcp_bundle/mcp_bundle.dart';
void main() {
final bundle = McpBundle.fromJson({
'manifest': {'id': 'com.example.shop', 'name': 'Shop', 'version': '1.0.0'},
'organization': {
'workspaces': [
{
'id': 'sales',
'kind': 'org',
'title': 'Sales',
'leadMemberId': 'kim',
'memberIds': ['kim'],
},
],
'members': [
{
'kind': 'person',
'id': 'kim',
'displayName': 'Kim',
'accounts': [
{'source': 'hub', 'uid': 'u_8f3a'},
],
},
],
},
});
final result = McpBundleValidator.validate(bundle);
print('valid: ${result.isValid}');
for (final e in result.errors) {
print('error ${e.code} at ${e.location}: ${e.message}');
}
final kim = bundle.organization!.findMember('kim')!;
print('${kim.displayName} signs in with '
'${kim.accounts.map((a) => '${a.source}:${a.uid}').join(', ')}');
// JSON out is the same shape JSON in.
print(bundle.toJson()['organization']);
}