Tool definition macros and utilities for Babashka MCP servers.
Tool definition macros and utilities for Babashka MCP servers.
(argmap m)Takes a {:keys [...]} argument map and extracts :type, :doc & :required to metadata.
Takes a {:keys [...]} argument map and extracts :type, :doc & :required to metadata.
(deftools name & tool-defs)Calls tools and binds to a symbol via def.
Calls tools and binds to a symbol via def.
(extract-mcp-meta m)Extracts MCP tool metadata from a {:keys [...]} map.
Extracts MCP tool metadata from a {:keys [...]} map.
(handler [map-arg] & body)Like fn but returns a fn with :mcp metadata for MCP Tool construction.
Like fn but returns a fn with :mcp metadata for MCP Tool construction.
(invoke-handler handler arg-map)Invokes tool handler & arg-map. Returns result or throws on exception.
Invokes tool handler & arg-map. Returns result or throws on exception.
(invoke-tool {:as tool :keys [handler args]} arg-map)1. Validates tool input parameters (missing args or wrong types)
2. Calls invoke-tool-handler, gathers result
3. Returns {:keys [success results errors]}(missing-elements required input)Returns seq of elements in required that are not present in input.
Returns seq of elements in required that are not present in input.
(missing-tool-args tool-args arg-map)Returns a seq of missing args or nil, for args with :required true.
Returns a seq of missing args or nil, for args with :required true.
(tool->json-schema {:as tool :keys [name doc]})Builds MCP-compatible {:keys [name description inputSchema]}.
Builds MCP-compatible {:keys [name description inputSchema]}.
(tool-v1 [tool-name & tool-body])Deprecated. Superseded by tool-v2-argmap, but still supported via tool.
Deprecated. Superseded by tool-v2-argmap, but still supported via tool.
(tool-v2-argmap [tool-name & tool-body])Primary tool definition macro using map destructuring.
Primary tool definition macro using map destructuring.
(tools & tool-defs)Returns a map of tool name => Tool.
Returns a map of tool name => Tool.
(validate-arg-types args arg-map)Validates argument types based on tool parameter definitions
Validates argument types based on tool parameter definitions
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |