Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions python/langchain-floo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__pycache__/
dist/
.venv/
21 changes: 21 additions & 0 deletions python/langchain-floo/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 floo contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
29 changes: 29 additions & 0 deletions python/langchain-floo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# langchain-floo

Load floo tools into a Python LangChain agent. The tools use the permissions of the floo API key supplied by the application.

Install from this repository:

```bash
python -m pip install 'langchain-floo @ git+https://github.com/getfloo/floo-cli.git#subdirectory=python/langchain-floo'
```

Set `FLOO_KEY` in your application environment. For a different floo environment, set `FLOO_API_URL` to its API base URL and use a key from that environment. To give an inventory assistant access to two read tools:

```python
import asyncio

from langchain_floo import load_floo_tools


async def main():
tools = await load_floo_tools(tool_names=["list_orgs", "list_apps"])
print([tool.name for tool in tools])


asyncio.run(main())
```

Pass the returned tools to LangChain's `create_agent`. Omit `tool_names` to load all tools exposed by floo to that credential. To supply the key from your application's secret store, pass `api_key` to `load_floo_tools`.

[floo MCP guide](https://getfloo.com/docs/guides/mcp#langchain)
21 changes: 21 additions & 0 deletions python/langchain-floo/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[build-system]
requires = ["hatchling>=1.27"]
build-backend = "hatchling.build"

[project]
name = "langchain-floo"
version = "0.1.0"
description = "Load floo application deployment and hosting tools into a LangChain agent."
requires-python = ">=3.10"
readme = "README.md"
license = "MIT"
license-files = ["LICENSE"]
authors = [{ name = "floo" }]
dependencies = ["langchain-mcp-adapters>=0.3.2,<0.4", "langchain-core>=1,<2"]

[project.urls]
Documentation = "https://getfloo.com/docs/guides/mcp#langchain"
Repository = "https://github.com/getfloo/floo-cli/tree/main/python/langchain-floo"

[tool.hatch.build.targets.wheel]
packages = ["src/langchain_floo"]
41 changes: 41 additions & 0 deletions python/langchain-floo/src/langchain_floo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""LangChain tools for the floo cloud."""

import os
from collections.abc import Collection

from langchain_core.tools import BaseTool
from langchain_mcp_adapters.client import MultiServerMCPClient


async def load_floo_tools(
*, api_key: str | None = None, tool_names: Collection[str] | None = None
) -> list[BaseTool]:
"""Discover floo tools for this credential, optionally selecting by exact name."""
key = api_key if api_key is not None else os.environ.get("FLOO_KEY")
if not key or not key.strip():
raise ValueError("Pass api_key or set FLOO_KEY to a floo API key.")
if isinstance(tool_names, str):
raise TypeError("Pass a collection of tool names, such as ['list_apps'].")

base_url = os.environ.get("FLOO_API_URL", "https://api.getfloo.com").rstrip("/")
client = MultiServerMCPClient(
{
"floo": {
"transport": "http",
"url": f"{base_url}/mcp",
"headers": {"Authorization": f"Bearer {key.strip()}"},
}
}
)
tools = await client.get_tools()
if tool_names is None:
return tools

selected = set(tool_names)
missing = selected.difference(tool.name for tool in tools)
if missing:
raise ValueError(f"Unavailable floo tools: {', '.join(sorted(missing))}")
return [tool for tool in tools if tool.name in selected]


__all__ = ["load_floo_tools"]
23 changes: 23 additions & 0 deletions python/langchain-floo/tests/test_tools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import unittest
from types import SimpleNamespace
from unittest.mock import AsyncMock, patch

from langchain_floo import load_floo_tools


class TestToolSelection(unittest.IsolatedAsyncioTestCase):
async def test_explicit_selection_does_not_expose_unrequested_tools(self):
read = SimpleNamespace(name="list_apps")
write = SimpleNamespace(name="create_app")
with (
patch.dict("os.environ", {"FLOO_API_URL": "https://example.test/"}),
patch("langchain_floo.MultiServerMCPClient") as client,
):
client.return_value.get_tools = AsyncMock(return_value=[read, write])
tools = await load_floo_tools(api_key="test", tool_names=["list_apps"])
self.assertEqual(tools, [read])
self.assertEqual(
client.call_args.args[0]["floo"]["url"], "https://example.test/mcp"
)
with self.assertRaisesRegex(ValueError, "missing_tool"):
await load_floo_tools(api_key="test", tool_names=["missing_tool"])