How to Use the Infracost MCP in LangChain
Prevent surprise cloud bills by chaining Infracost cost checks directly into your LangChain multi-step reasoning pipelines.
Works with every AI agent you already use
…and any MCP-compatible client
Connect Infracost MCP to LangChain
Create your Vinkius account to connect Infracost to LangChain and route execution through our secure gateway. The platform manages server hosting, runtime updates, and security layers. Configuration requires no manual server provisioning.
Cost Guardrails in LangChain Pipelines
Your LangChain agent runs `create_guardrail` via the MCP server to enforce budget limits before code hits production. This tool sets hard thresholds on your Terraform runs, stopping runaway cloud spend before it starts. LangSmith traces every step of this process, showing you the exact inputs and outputs of `list_guardrails` and `get_guardrail`. You get full visibility into how your agent evaluates cost rules without digging through raw logs.
Custom Enterprise Price Books via MCP Server
Large teams do not pay list price for cloud resources, so this MCP Server lets your LangChain chain run `create_price_book` to ingest negotiated rates. The agent fetches a presigned upload link with `get_price_book_files_url` and kicks off the ingestion using `ingest_price_book`. Once uploaded, the agent updates your organizational profile via `update_organization` to activate the new rates. This ensures your cost estimates match your actual enterprise discounts instead of generic public pricing.
Automated Tagging Policy Enforcement
Missing tags break cost allocation, which is why your LangChain agent executes `update_tagging_policy` to keep infrastructure organized. The agent checks current resources against your standards and updates allowed values dynamically. Coupling this with `upload_custom_properties` lets you pull metadata from internal catalogs to map costs to specific cost centers. Your chain handles the entire reconciliation loop without manual developer intervention.
Set up Infracost MCP in LangChain
Prerequisites
- Python 3.10+ installed
-
langchain-mcp-adapters+langgraphpackages - Active Vinkius subscription with a valid endpoint token
- 1
Install dependencies
Run
pip install langchain-mcp-adapters langgraph langchain-openai. The MCP adapters package converts MCP tools into native LangChainBaseToolobjects. - 2
Connect via HTTP transport
Use
MultiServerMCPClientwith"transport": "http"pointing to your Vinkius endpoint. Replace[YOUR_TOKEN_HERE]with your token from cloud.vinkius.com. - 3
Create a ReAct agent
Pass the discovered tools to
create_react_agent()from LangGraph. The agent automatically routes Infracost tool calls through the MCP protocol. - 4
Run with any LLM
Swap
ChatOpenAIforChatAnthropic,ChatGoogleGenerativeAI, or any LangChain-compatible model. The MCP tools work identically across all providers.
from langchain_mcp_adapters.client import MultiServerMCPClient
from langgraph.prebuilt import create_react_agent
from langchain_openai import ChatOpenAI
async with MultiServerMCPClient({
"infracost-mcp": {
"transport": "http",
"url": "https://edge.vinkius.com/[YOUR_TOKEN_HERE]/mcp",
}
}) as client:
tools = client.get_tools()
agent = create_react_agent(
ChatOpenAI(model="gpt-4o"),
tools,
)
result = await agent.ainvoke({
"messages": "List recent Infracost transactions"
})
print(result["messages"][-1].content) Independent Platform Disclaimer: Vinkius is an independent platform and is not affiliated with, endorsed by, sponsored by, verified by, or otherwise authorized by Infracost. All third-party trademarks, logos, and brand names are the property of their respective owners. Their use on this website is strictly for informational purposes to identify service compatibility and interoperability.
Why Choose Vinkius
Vinkius connects your tools to AI with real-time monitoring and automatic cost savings — all from one dashboard.
Real-time monitoring
Live
visibility into every interaction
Connect your favorite tools to your AI and see exactly what's happening — every request, every response, in real time.
Built-in savings
60%
lower AI costs
Vinkius compresses data between your apps and your AI automatically. Lower bills every month — no configuration required.
Single dashboard
One
place for every integration
Every tool your AI connects to, managed from a single screen. One account, complete control.
Common questions about Infracost MCP in LangChain
Use it with your favorite AI tools
Connect this server to Cursor, Claude, VS Code, and more.
Start using the Infracost MCP today
We host it, we monitor it, we maintain it. You just paste one token.