Connect your agent

LangChain & LlamaIndex

Vlozi MCP as a Tool collection in LangChain or LlamaIndex agents.

Slots in as native Tool objects. No SDK rewrite.

LangChain

import { DynamicStructuredTool } from "@langchain/core/tools";
import { AgentExecutor, createToolCallingAgent } from "langchain/agents";
import { ChatAnthropic } from "@langchain/anthropic";
import { ChatPromptTemplate } from "@langchain/core/prompts";
import { z } from "zod";
 
const VLOZI_KEY = process.env.VLOZI_API_KEY!;
const MCP = "https://mcp.vlozi.app";
 
async function fetchVloziTools() {
  const r = await fetch(`${MCP}/tools`, {
    headers: { Authorization: `Bearer ${VLOZI_KEY}` },
  });
  const { data } = await r.json();
  return data.tools.map((t: any) =>
    new DynamicStructuredTool({
      name: t.name.replace(".", "_"),
      description: t.description,
      // For richer typing use `json-schema-to-zod` from npm.
      schema: z.object({}).passthrough(),
      func: async (input) => {
        const r = await fetch(`${MCP}/tools/${t.name}`, {
          method: "POST",
          headers: {
            Authorization: `Bearer ${VLOZI_KEY}`,
            "content-type": "application/json",
            "x-agent-id": "langchain-agent",
          },
          body: JSON.stringify(input),
        });
        return JSON.stringify(await r.json());
      },
    })
  );
}
 
const tools = await fetchVloziTools();
const llm = new ChatAnthropic({ model: "claude-sonnet-4-6" });
const prompt = ChatPromptTemplate.fromMessages([
  ["system", "You manage a Vlozi workspace."],
  ["human", "{input}"],
  ["placeholder", "{agent_scratchpad}"],
]);
 
const agent = await createToolCallingAgent({ llm, tools, prompt });
const executor = new AgentExecutor({ agent, tools });
 
await executor.invoke({ input: "Draft a Q2 retrospective tagged 'quarterly'." });

Python LangChain follows the same shape — StructuredTool.from_function, create_tool_calling_agent, AgentExecutor. Map 1-to-1.

LlamaIndex

Same pattern, wrapped as FunctionTool:

from llama_index.core.tools import FunctionTool
import requests, os, json
 
def make_tool(meta):
    name = meta["name"]
    def fn(**kwargs):
        r = requests.post(
            f"https://mcp.vlozi.app/tools/{name}",
            headers={"Authorization": f"Bearer {os.environ['VLOZI_API_KEY']}"},
            json=kwargs,
        )
        return json.dumps(r.json())
    return FunctionTool.from_defaults(
        fn=fn, name=name.replace(".", "_"), description=meta["description"],
    )

Pass the result of [make_tool(m) for m in tools_list] to ReActAgent.from_tools(...).

Other frameworks

The three steps generalize to Haystack, CrewAI, AutoGPT, Semantic Kernel, Vercel AI SDK:

  1. GET /tools to discover
  2. Wrap each descriptor as the framework's native tool type
  3. Forward calls to POST /tools/<name>, return the JSON
MCP · Connect your agentEdit on GitHub