Typed Composition with MCP: Experiments from Dagger
Written by Om-Shree-0709 on .
- Object-Oriented Tool Composition via MCP
- Intuition: From Build Graphs to Tool Graphs
- Implementation: Dagger + MCP
- Key Observations
- Final Thoughts
- Acknowledgements
- References
Object-Oriented Tool Composition via MCP
When LLMs execute real software functions via MCP, tool composition becomes a challenge. Most tool-calling environments treat tools as flat namespaces. But what happens when the tools involve objects—like containers—that return rich, nested state and expose further operations?
This is the composition puzzle explored by Solomon Hykes, co-founder of Dagger, in a talk that bridges CI/CD workflows, object-based function chaining, and agent orchestration over MCP1.
Intuition: From Build Graphs to Tool Graphs
Dagger began as a programmable, container-native build engine for CI/CD. It enables developers to define ephemeral workflows made of composable functions—like creating a container, modifying its contents, and chaining steps. These functions return objects rather than flat results. Each object exposes further methods—like adding files or spawning shells1.
This mirrors how LLMs build up context: one message at a time, immutable and referential. So what if LLMs could orchestrate these function chains? And what if we wanted to do this not just with raw tool-calling, but via the MCP protocol?
Implementation: Dagger + MCP
Dagger exposes its function-based API through multiple SDKs (Go, TS, Python). Internally, every command returns an object ID that can be further operated on. For example:
In their prototype, the Dagger team made this system MCP-compatible using goose
, a lightweight open-source MCP client. They bound the entire function tree as tool calls accessible to LLMs. Then they extended this with a prompt mode, where the LLM can compose these tools directly2.
To handle object-based composition, they wrapped MCP calls with helper methods like select_methods
and list_methods
, allowing LLMs to browse and operate on objects like containers—essentially extending MCP’s flat namespace into a richer graph model.
Key Observations
- LLMs are excellent at chaining functions, even across object types—but they need help managing object scope.
- Sandboxing matters: ephemeral container namespaces are critical when agents execute real code.
- Caching comes for free in DAG-based execution: a huge win for repeatable agent behaviors.
- Traces: Every LLM interaction with Dagger over MCP is fully traced, enabling inspection and debugging.
- Custom types: Developers can extend Dagger’s API using Go or TS—instantly available to MCP-aware agents3.
Final Thoughts
Object-oriented tool composition is the next evolution of LLM-agent programming. Solomon's experiments with Dagger show how MCP can move beyond flat tool schemas into structured, traceable, and safe execution models—bringing us closer to robust, intelligent automation workflows1.
Acknowledgements
This guide is based on Solomon Hykes's enlightening talk at the "Typed Composition with MCP" session at the MCP Developer Summit, where he explored container-based execution, DAG function orchestration, and the role of MCP in enabling structured agent workflows.
Special thanks to the Anthropic team and the broader MCP developer community for fostering these cutting-edge conversations around agent protocol design.
References
Footnotes
Written by Om-Shree-0709 (@Om-Shree-0709)