McpServer.JS (HTTP MCP Server v0.8.0)
View SourceProvides inline JavaScript helpers for MCP Apps.
Use mcp_app_script/1 to embed the McpApp client class directly
into an HTML template (e.g., EEx) so the iframe app has no external
script dependencies. Server info from the MCP connection is baked
into the script as default appInfo and protocolVersion.
Example
# In a .html.eex template:
<script><%= McpServer.JS.mcp_app_script(conn) %></script>
Summary
Functions
Renders priv/js/mcp_app.js.eex with server info from the MCP connection.
Functions
@spec mcp_app_script(McpServer.Conn.t()) :: String.t()
Renders priv/js/mcp_app.js.eex with server info from the MCP connection.
The server_info stored in conn.private[:server_info] (a map with
:name and :version keys) is used as the default appInfo in the
generated McpApp class.
Parameters
conn— AMcpServer.Connstruct (the one your controllers receive).