Add opt-in tool-call verification hook for credential/trust-card checks (langchain-core)
Submission checklist
- This is a feature request, not a bug report or usage question.
- I added a clear and descriptive title that summarizes the feature request.
- I used the GitHub search to find a similar feature request and didn't find it.
- I checked the LangChain documentation and API reference to see if this feature already exists.
- This is not related to the langchain-community package.
Package (Required)
- langchain
- langchain-openai
- langchain-anthropic
- langchain-classic
- langchain-core
- langchain-model-profiles
- langchain-tests
- langchain-text-splitters
- langchain-chroma
- langchain-deepseek
- langchain-exa
- langchain-fireworks
- langchain-groq
- langchain-huggingface
- langchain-mistralai
- langchain-nomic
- langchain-ollama
- langchain-openrouter
- langchain-perplexity
- langchain-qdrant
- langchain-xai
- Other / not sure / general
Feature Description
An opt-in verification hook for tool calls (including MCP adapter calls): before a tool executes, an application-supplied verifier callback can check the tool's credential / trust card and block non-PERMIT decisions.
Today, an agent can dispatch tools — in particular MCP servers — whose credentials cannot be authenticated, and there is no canonical, fail-closed interception point for credential verification in the tool loop.
Use Case
I'm building agents that call MCP servers and other credential-bearing tools. Currently, to authenticate a tool's issuer before dispatch, I have to wrap every tool manually. An opt-in hook in the tool loop would let applications fail closed when a tool's credential fails verification — directly addressing the MCP trust gap discussed in #21768.
The verifier itself ships as an external package (marketnow-trust, Python; @marketnow/trust-core, TypeScript — zero runtime deps); this request is about the hook surface, not about bundling any vendor code.
Proposed Solution
Optional verify hook (or middleware) invoked before tool execution for both sync and async tools, with the decision (PERMIT / DENY + reason) surfaced to the callback. Nothing enabled by default; no protocol changes; works with stock MCP servers. We're happy to contribute a recipe / example using the external verifier if that's more acceptable than a core hook. Open-source source repo: https://github.com/alicelabs-llc/universal-trust-adapter
Note: earlier versions of this proposal were submitted as #40100 and #40102 and were auto-closed by triage as programmatic submissions (and re-attempted as #40157); this manual resubmission follows the template policy.
Alternatives Considered
No response
Additional Context
No response
Social handles (optional)
No response
Source: langchain-ai/langchain