baml icon indicating copy to clipboard operation
baml copied to clipboard

When developing an Agent with BAML, how to integrate the MCP server?

Open jtsang4 opened this issue 8 months ago • 4 comments

Hello, I'm trying to integrate BAML with an MCP server, and I'm running into a challenge with function calling. The BAML documentation (https://docs.boundaryml.com/examples/prompt-engineering/tools-function-calling) shows how to dynamically generate parameter signatures for a single function.

However, in my use case with the MCP server, I have multiple functions with dynamically defined signatures that the BAML model needs to be able to call. I'm unsure how to best approach this. Is there existing support for handling multiple dynamic function definitions, or is there a recommended workaround?

jtsang4 avatar May 07 '25 22:05 jtsang4

BAML is like "React for AI Engineering instead of frontend" - it provides a robust and extensible foundation

For BAML to efficiently provide high value for AI Engineering, in my personal opinion, there needs to be layers on top (just like Next.JS or React UI component libraries exist on top of React)

I did some experimentation for building this layer on top with baml-agents

Let me know what you think

P.S. The wrapper syntax in the demo is a bit outdated, a much more clean API for using MCP tools can be achieved with runtime hooks as described here and implemented here.

Elijas avatar May 09 '25 08:05 Elijas

@Elijas love the page here. Would you mind if we made this as a PR into our docs directly (and link + credit you?)

hellovai avatar May 09 '25 12:05 hellovai

That would be dope! 🚀 Feel free to change/rewrite any parts, both code and docs

Please keep in mind though, that the current implementation is much more of a back-of-napkin proof of concept, than a stable unit-tested SDK that I would expect when incorporating things recommended in BAML docs

Also, the current demo code and baml-agents APi could be made much more elegant too - some work will be needed there as well in the future

Elijas avatar May 09 '25 15:05 Elijas