agentsml-impl 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. agentsml_impl/__init__.py +3 -0
  2. agentsml_impl/cli.py +472 -0
  3. agentsml_impl/compiler/__init__.py +1 -0
  4. agentsml_impl/compiler/capabilities.py +330 -0
  5. agentsml_impl/compiler/conditions.py +177 -0
  6. agentsml_impl/compiler/diagnostics.py +112 -0
  7. agentsml_impl/compiler/durations.py +31 -0
  8. agentsml_impl/compiler/expressions.py +123 -0
  9. agentsml_impl/compiler/identifiers.py +60 -0
  10. agentsml_impl/compiler/ir.py +391 -0
  11. agentsml_impl/compiler/limits.py +28 -0
  12. agentsml_impl/compiler/loader.py +83 -0
  13. agentsml_impl/compiler/naming.py +87 -0
  14. agentsml_impl/compiler/planner.py +79 -0
  15. agentsml_impl/compiler/render.py +90 -0
  16. agentsml_impl/compiler/schema_validation.py +121 -0
  17. agentsml_impl/compiler/semantic_validation.py +424 -0
  18. agentsml_impl/protocols/__init__.py +1 -0
  19. agentsml_impl/runtime/__init__.py +1 -0
  20. agentsml_impl/runtime/events.py +59 -0
  21. agentsml_impl/runtime/json_schema.py +138 -0
  22. agentsml_impl/runtime/tools.py +145 -0
  23. agentsml_impl/schemas/agentsml.schema.json +406 -0
  24. agentsml_impl/schemas/v0.1/agentsml.schema.json +628 -0
  25. agentsml_impl/schemas/v0.2/agentsml.schema.json +363 -0
  26. agentsml_impl/schemas/v0.3/agentsml.schema.json +406 -0
  27. agentsml_impl/targets/__init__.py +1 -0
  28. agentsml_impl/targets/a2a/__init__.py +0 -0
  29. agentsml_impl/targets/a2a/adapter.py +94 -0
  30. agentsml_impl/targets/a2a/capabilities.yaml +25 -0
  31. agentsml_impl/targets/ag2/__init__.py +0 -0
  32. agentsml_impl/targets/ag2/adapter.py +655 -0
  33. agentsml_impl/targets/ag2/capabilities.yaml +37 -0
  34. agentsml_impl/targets/ag_ui/__init__.py +0 -0
  35. agentsml_impl/targets/ag_ui/adapter.py +123 -0
  36. agentsml_impl/targets/ag_ui/capabilities.yaml +25 -0
  37. agentsml_impl/targets/agno/__init__.py +0 -0
  38. agentsml_impl/targets/agno/adapter.py +191 -0
  39. agentsml_impl/targets/agno/capabilities.yaml +26 -0
  40. agentsml_impl/targets/ap2/__init__.py +0 -0
  41. agentsml_impl/targets/ap2/adapter.py +84 -0
  42. agentsml_impl/targets/ap2/capabilities.yaml +25 -0
  43. agentsml_impl/targets/base.py +157 -0
  44. agentsml_impl/targets/bedrock_agentcore/__init__.py +0 -0
  45. agentsml_impl/targets/bedrock_agentcore/adapter.py +592 -0
  46. agentsml_impl/targets/bedrock_agentcore/capabilities.yaml +26 -0
  47. agentsml_impl/targets/claude_agent_sdk/__init__.py +0 -0
  48. agentsml_impl/targets/claude_agent_sdk/adapter.py +178 -0
  49. agentsml_impl/targets/claude_agent_sdk/capabilities.yaml +26 -0
  50. agentsml_impl/targets/crewai/__init__.py +0 -0
  51. agentsml_impl/targets/crewai/adapter.py +441 -0
  52. agentsml_impl/targets/crewai/capabilities.yaml +30 -0
  53. agentsml_impl/targets/databricks/__init__.py +0 -0
  54. agentsml_impl/targets/databricks/adapter.py +427 -0
  55. agentsml_impl/targets/databricks/capabilities.yaml +26 -0
  56. agentsml_impl/targets/flowise/__init__.py +0 -0
  57. agentsml_impl/targets/flowise/adapter.py +71 -0
  58. agentsml_impl/targets/flowise/capabilities.yaml +26 -0
  59. agentsml_impl/targets/google_adk/__init__.py +0 -0
  60. agentsml_impl/targets/google_adk/adapter.py +589 -0
  61. agentsml_impl/targets/google_adk/capabilities.yaml +36 -0
  62. agentsml_impl/targets/langchain/__init__.py +1 -0
  63. agentsml_impl/targets/langchain/adapter.py +351 -0
  64. agentsml_impl/targets/langchain/capabilities.yaml +30 -0
  65. agentsml_impl/targets/langflow/__init__.py +0 -0
  66. agentsml_impl/targets/langflow/adapter.py +147 -0
  67. agentsml_impl/targets/langflow/capabilities.yaml +26 -0
  68. agentsml_impl/targets/langgraph/__init__.py +0 -0
  69. agentsml_impl/targets/langgraph/adapter.py +911 -0
  70. agentsml_impl/targets/langgraph/capabilities.yaml +33 -0
  71. agentsml_impl/targets/llamaindex/__init__.py +1 -0
  72. agentsml_impl/targets/llamaindex/adapter.py +406 -0
  73. agentsml_impl/targets/llamaindex/capabilities.yaml +31 -0
  74. agentsml_impl/targets/lyzr/__init__.py +0 -0
  75. agentsml_impl/targets/lyzr/adapter.py +146 -0
  76. agentsml_impl/targets/lyzr/capabilities.yaml +26 -0
  77. agentsml_impl/targets/mastra/__init__.py +0 -0
  78. agentsml_impl/targets/mastra/adapter.py +635 -0
  79. agentsml_impl/targets/mastra/capabilities.yaml +32 -0
  80. agentsml_impl/targets/mcp_server/__init__.py +0 -0
  81. agentsml_impl/targets/mcp_server/adapter.py +141 -0
  82. agentsml_impl/targets/mcp_server/capabilities.yaml +25 -0
  83. agentsml_impl/targets/microsoft_agent_framework/__init__.py +0 -0
  84. agentsml_impl/targets/microsoft_agent_framework/adapter.py +563 -0
  85. agentsml_impl/targets/microsoft_agent_framework/capabilities.yaml +26 -0
  86. agentsml_impl/targets/n8n/__init__.py +0 -0
  87. agentsml_impl/targets/n8n/adapter.py +139 -0
  88. agentsml_impl/targets/n8n/capabilities.yaml +26 -0
  89. agentsml_impl/targets/openai_agents/__init__.py +0 -0
  90. agentsml_impl/targets/openai_agents/adapter.py +175 -0
  91. agentsml_impl/targets/openai_agents/capabilities.yaml +27 -0
  92. agentsml_impl/targets/pydantic_ai/__init__.py +0 -0
  93. agentsml_impl/targets/pydantic_ai/adapter.py +922 -0
  94. agentsml_impl/targets/pydantic_ai/capabilities.yaml +37 -0
  95. agentsml_impl/targets/registry.py +290 -0
  96. agentsml_impl/targets/relevance_ai/__init__.py +0 -0
  97. agentsml_impl/targets/relevance_ai/adapter.py +66 -0
  98. agentsml_impl/targets/relevance_ai/capabilities.yaml +26 -0
  99. agentsml_impl/targets/smolagents/__init__.py +0 -0
  100. agentsml_impl/targets/smolagents/adapter.py +210 -0
  101. agentsml_impl/targets/smolagents/capabilities.yaml +27 -0
  102. agentsml_impl/targets/snowflake_cortex/__init__.py +0 -0
  103. agentsml_impl/targets/snowflake_cortex/adapter.py +167 -0
  104. agentsml_impl/targets/snowflake_cortex/capabilities.yaml +26 -0
  105. agentsml_impl/targets/spring_ai/__init__.py +1 -0
  106. agentsml_impl/targets/spring_ai/adapter.py +626 -0
  107. agentsml_impl/targets/spring_ai/capabilities.yaml +31 -0
  108. agentsml_impl/targets/strands_agents/__init__.py +1 -0
  109. agentsml_impl/targets/strands_agents/adapter.py +309 -0
  110. agentsml_impl/targets/strands_agents/capabilities.yaml +29 -0
  111. agentsml_impl/targets/support_matrix.py +91 -0
  112. agentsml_impl/targets/ucp/__init__.py +0 -0
  113. agentsml_impl/targets/ucp/adapter.py +86 -0
  114. agentsml_impl/targets/ucp/capabilities.yaml +25 -0
  115. agentsml_impl/targets/vercel_ai/__init__.py +1 -0
  116. agentsml_impl/targets/vercel_ai/adapter.py +349 -0
  117. agentsml_impl/targets/vercel_ai/capabilities.yaml +30 -0
  118. agentsml_impl/targets/vertex_agent_engine/__init__.py +0 -0
  119. agentsml_impl/targets/vertex_agent_engine/adapter.py +407 -0
  120. agentsml_impl/targets/vertex_agent_engine/capabilities.yaml +26 -0
  121. agentsml_impl/targets/zapier_agents/__init__.py +0 -0
  122. agentsml_impl/targets/zapier_agents/adapter.py +106 -0
  123. agentsml_impl/targets/zapier_agents/capabilities.yaml +26 -0
  124. agentsml_impl-0.2.0.dist-info/METADATA +109 -0
  125. agentsml_impl-0.2.0.dist-info/RECORD +129 -0
  126. agentsml_impl-0.2.0.dist-info/WHEEL +5 -0
  127. agentsml_impl-0.2.0.dist-info/entry_points.txt +3 -0
  128. agentsml_impl-0.2.0.dist-info/licenses/LICENSE +28 -0
  129. agentsml_impl-0.2.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,141 @@
1
+ """MCP Server target adapter — Level 1 code generation."""
2
+
3
+ from __future__ import annotations
4
+ from pathlib import Path
5
+
6
+ from agentsml_impl.compiler.identifiers import python_identifier_ir
7
+ from agentsml_impl.compiler.ir import AgentSystemIR
8
+ from agentsml_impl.compiler.diagnostics import DiagCode, DiagnosticSet
9
+ from agentsml_impl.compiler.planner import GenerationPlan
10
+ from agentsml_impl.compiler.render import write_file
11
+ from agentsml_impl.runtime.tools import generate_tools_module
12
+ from agentsml_impl.targets.base import TargetAdapter, GenerationResult
13
+
14
+
15
+ class Adapter(TargetAdapter):
16
+ @property
17
+ def name(self) -> str:
18
+ return "mcp-server"
19
+
20
+ def analyze(self, ir: AgentSystemIR, diagnostics: DiagnosticSet) -> None:
21
+ pass
22
+
23
+ def generate(self, ir: AgentSystemIR, plan: GenerationPlan,
24
+ out_dir: Path, diagnostics: DiagnosticSet) -> GenerationResult:
25
+ ir = python_identifier_ir(ir)
26
+ out_dir.mkdir(parents=True, exist_ok=True)
27
+ pkg = plan.package_name
28
+ src = out_dir / "src" / pkg
29
+ src.mkdir(parents=True, exist_ok=True)
30
+
31
+ files: list[str] = []
32
+ files += _write_pyproject(ir, plan, out_dir)
33
+ files += _write_tools(ir, src, out_dir, diagnostics)
34
+ files += _write_server(ir, plan, src, out_dir)
35
+ files += _write_init(src, out_dir)
36
+ files += _write_readme(ir, plan, out_dir)
37
+
38
+ return GenerationResult(
39
+ target=self.name, out_dir=out_dir, files_written=files, success=True
40
+ )
41
+
42
+
43
+ def _write_pyproject(ir: AgentSystemIR, plan: GenerationPlan, out_dir: Path) -> list[str]:
44
+ c = f'''\
45
+ [build-system]
46
+ requires = ["setuptools>=68"]
47
+ build-backend = "setuptools.build_meta"
48
+
49
+ [project]
50
+ name = "{plan.package_name}-mcp"
51
+ version = "{ir.metadata.version or '0.1.0'}"
52
+ description = "MCP Server for {plan.project_name}"
53
+ requires-python = ">=3.11"
54
+ dependencies = [
55
+ "mcp",
56
+ "pydantic"
57
+ ]
58
+
59
+ [project.scripts]
60
+ {plan.package_name}-mcp = "{plan.package_name}.server:main"
61
+
62
+ [tool.setuptools.packages.find]
63
+ where = ["src"]
64
+ '''
65
+ write_file(out_dir, "pyproject.toml", c)
66
+ return ["pyproject.toml"]
67
+
68
+
69
+ def _write_tools(ir: AgentSystemIR, src: Path, out_dir: Path, ds: DiagnosticSet) -> list[str]:
70
+ if not ir.tools:
71
+ return []
72
+ c = generate_tools_module(ir.tools, ds, framework="mcp_server", decorator="")
73
+ rel = f"src/{src.name}/tools.py"
74
+ write_file(out_dir, rel, c)
75
+ return [rel]
76
+
77
+
78
+ def _write_server(ir: AgentSystemIR, plan: GenerationPlan, src: Path, out_dir: Path) -> list[str]:
79
+ # Use FastMCP or direct mcp server
80
+ local_tools = [t for t in ir.tools.values() if not t.is_mcp() and not t.is_openapi()]
81
+ tools_import = f"from .tools import {', '.join(t.key for t in local_tools)}" if local_tools else ""
82
+
83
+ tool_regs = []
84
+ for t in local_tools:
85
+ tool_regs.append(f'mcp.tool()({t.key})')
86
+
87
+ c = f'''\
88
+ """MCP Server for {plan.project_name}."""
89
+ from __future__ import annotations
90
+ from mcp.server.fastmcp import FastMCP
91
+ {tools_import}
92
+
93
+ mcp = FastMCP("{plan.project_name}")
94
+
95
+ # Register tools
96
+ {chr(10).join(tool_regs)}
97
+
98
+ def main():
99
+ """Run the MCP server."""
100
+ mcp.run(transport="stdio")
101
+
102
+ if __name__ == "__main__":
103
+ main()
104
+ '''
105
+ rel = f"src/{src.name}/server.py"
106
+ write_file(out_dir, rel, c)
107
+ return [rel]
108
+
109
+ def _write_init(src: Path, out_dir: Path) -> list[str]:
110
+ c = f'"""Package: {src.name}."""\n'
111
+ rel = f"src/{src.name}/__init__.py"
112
+ write_file(out_dir, rel, c)
113
+ return [rel]
114
+
115
+ def _write_readme(ir: AgentSystemIR, plan: GenerationPlan, out_dir: Path) -> list[str]:
116
+ c = f"""\
117
+ # {plan.project_name} — MCP Server
118
+
119
+ Generated by `agentsml-impl`.
120
+ Exposes the local tools from the AgentsML definition as MCP tools.
121
+
122
+ ## Quickstart
123
+ ```bash
124
+ pip install -e .
125
+ {plan.package_name}-mcp
126
+ ```
127
+
128
+ ## Setup in Claude Desktop
129
+ Add this to your `claude_desktop_config.json`:
130
+ ```json
131
+ {{
132
+ "mcpServers": {{
133
+ "{plan.package_name}": {{
134
+ "command": "{plan.package_name}-mcp"
135
+ }}
136
+ }}
137
+ }}
138
+ ```
139
+ """
140
+ write_file(out_dir, "README.md", c)
141
+ return ["README.md"]
@@ -0,0 +1,25 @@
1
+ target: mcp_server
2
+ kind: protocol
3
+ language: python
4
+ status: implemented
5
+ level: 1
6
+ version_tested: "1.0.0"
7
+ supports:
8
+ agents: unsupported
9
+ tools: native
10
+ workflows: unsupported
11
+ graph_edges: unsupported
12
+ graph_conditions: unsupported
13
+ cycles: unsupported
14
+ parallel: unsupported
15
+ human_approval: unsupported
16
+ mcp: native
17
+ a2a: unsupported
18
+ ag_ui: unsupported
19
+ structured_output: unsupported
20
+ observability: unsupported
21
+ artifacts:
22
+ - python_project
23
+ - readme
24
+ notes: >
25
+ Generates an MCP server exposing the local tools defined in the AgentsML spec.