Ortus Solutions today announces BoxLang AI 3.8.0, the release that makes multi-user AI applications a first-class citizen. Your agents can now sign in to OAuth-protected MCP servers on behalf of each person who talks to them, and every memory type keeps each user and conversation apart. Alongside of a slew of more bug fixes, BoxLang AI 3.8 is a solid release. Let's see how easily we can connect to an MCP server using oAuth:
mcpClient = MCP( "https://mail.example.com/mcp" ).withOAuth( {
redirectUri : "https://app.example.com/oauth/callback"
} )
// Send the person to the sign-in page
started = mcpClient.startAuthorization( "alice" )
location( started.authorizationUrl )
That is a full OAuth sign-in to an MCP server. Discovery, client registration, PKCE, token refresh: handled. 🔐
install-bx-module bx-ai
Agents that work for people, not just for you
Most MCP servers worth connecting to (mail, calendars, issue trackers) don't take a shared API key. They ask each person to sign in, then hand out access tokens that expire. Until now, that meant writing the authorization dance yourself, and then figuring out how one agent could serve many users without mixing up their accounts.
3.8.0 solves both halves:
- OAuth for MCP clients, following the MCP authorization specification
- Per-person tokens, so Alice's agent reads Alice's inbox and Bob's reads Bob's
- Memory that is scoped to user and conversation, so what Alice said never lands in Bob's prompt
Let's take them in turn.
OAuth for MCP: withOAuth()
Call withOAuth() on any HTTP MCP client and BoxLang AI takes over the protocol:

Here is what happens under the hood:
- Discovery. The client reads the server's Protected Resource Metadata, then the authorization server's metadata.
- A client ID. Use one you registered, a Client ID Metadata Document, or Dynamic Client Registration. The registration is stored, so it happens once.
- Sign-in with PKCE (S256).
startAuthorization()returns the sign-in address, including theresourceparameter so the token is for that MCP server. - Callback.
completeAuthorization()checks thestateand theissof the callback, then trades the code for tokens. - Every request carries
Authorization: Bearer. Tokens are refreshed before they expire, and a401triggers one refresh and one retry.
Your application owns exactly two things: the redirect to the sign-in page and the callback route.
// https://app.example.com/oauth/callback
signedIn = mcpClient.completeAuthorization( url.code, url.state, url.iss ?: "" )
// From now on the client is signed in
tools = mcpClient.listTools()
response = mcpClient.send( "inbox", {} )
Security is on by default. Every address in the flow must be https (plain http only for localhost), and an authorization server that doesn't advertise PKCE S256 is refused.
One client, many people
The subject option decides whose tokens a call uses. Give it a function and a single shared client serves your whole user base:
mcpClient = MCP( "https://mail.example.com/mcp" ).withOAuth( {
redirectUri : "https://app.example.com/oauth/callback",
subject : ( context ) => context.chatRequest.getUserId()
} )
mcpClient.isAuthorized( "alice" ) // true once she has signed in
mcpClient.isAuthorized( "bob" ) // false: Bob hasn't signed in yet
Tools that agents build from an MCP server pass the chat request as context, so getUserId() is the person talking to the agent. Hand the same config to an agent and you're done:
agent = aiAgent(
name : "mail-agent",
model : aiModel( provider: "openai" ),
mcpServers : [
{
url : "https://mail.example.com/mcp",
oauth : {
redirectUri : "https://app.example.com/oauth/callback",
subject : ( context ) => context.chatRequest.getUserId()
}
}
]
)
Two details worth knowing:
discoverySubjectcovers calls that have no chat context, such as listing tools when the agent starts. Before 3.8.0 these always used"default". Now you can name whose sign-in to use.- A server nobody has signed in to yet is skipped at startup. After the first sign-in, pass the signed-in client with
withMCPServer().
Know when someone needs to sign in
When a call can't go through because the person has no usable tokens, the client doesn't hit the server. It returns a failed response and fires the new onMCPAuthorizationRequired event with a reason:
| Reason | Means |
|---|---|
no_token | No tokens, or they were refused on refresh |
unauthorized | The server answered 401 even for a fresh token |
insufficient_scope | The server wants more scope. Read event.scope and sign in again |
BoxRegisterInterceptor( ( event ) => {
// event.subject, event.reason, event.baseURL, event.scope, event.client
link = event.client.startAuthorization( event.subject ).authorizationUrl
// show the person a "Connect your account" button that points at link
}, "onMCPAuthorizationRequired" )
Your chat UI can turn that event into a friendly "Connect your mail account" prompt, right when the agent needs it.
Token stores you can trust (or replace)
Tokens, client registrations and pending sign-ins live in an IMCPTokenStore. Three ship with BoxLang AI:
| Store | Where tokens live |
|---|---|
cache (default) | A BoxLang cache. In memory by default, durable with a Redis or file-backed cache |
file | One JSON file per record |
jdbc | A table, created when missing |
Pick one with store: "cache" | "file" | "jdbc". The file and JDBC stores keep tokens as plain text, so protect the folder or table. Or write your own. The contract is three methods, which makes an encrypting store easy:
class implements="bxModules.bxai.models.mcp.oauth.IMCPTokenStore" {
function init( required any vault ) {
variables.vault = arguments.vault
return this
}
struct function get( required string key ) {
var sealed = variables.vault.read( arguments.key )
return isNull( sealed ) ? {} : jsonDeserialize( variables.vault.open( sealed ) )
}
void function set( required string key, required struct value, numeric ttlSeconds = 0 ) {
variables.vault.write( arguments.key, variables.vault.seal( jsonSerialize( arguments.value ) ), arguments.ttlSeconds )
}
void function remove( required string key ) {
variables.vault.delete( arguments.key )
}
}
Seal in set(), open in get(), and your tokens never touch disk in the clear. Full details are in the release notes and the MCP OAuth guide in the module docs.
Memory that keeps people apart
Agents serve many users through the userId and conversationId of each call. In 3.8.0 every memory type honors both.

What changed:
- Window and summary memory now keep a separate message list per user and conversation.
windowis the default memory, so an agent built withaiAgent()and run with{ userId, conversationId }now gives each person their own history. - JDBC memory now uses a row per user and conversation, keyed
<key>::<userId>::<conversationId>. No table change is needed. - Gateways now run every turn with a
conversationId(and auserIdwhen the platform names the sender). A conversation is the chat namespaced by its gateway, such astelegram:42, plus the platform thread when there is one, such astelegram:42: topic-7. A Telegram forum topic or a Slack thread is its own conversation.
Window and summary memory live in the process, so they reset on restart and aren't shared across servers. For that, use cache or jdbc memory. To bound the footprint, the new maxConversations option caps how many other scopes a memory keeps (default 1000, 0 for no limit). Past the cap, the least recently used scope is dropped:
memory = aiMemory( memory: "window", config: { maxConversations: 500 } )
Want a chat to move to another conversation, say a /new command that starts fresh? Override resolveConversationId() on the gateway session. Override turnOptions() if you'd rather name the identity another way, for example with a platform-qualified user id:
class extends="bxModules.bxai.models.gateway.GatewaySession" {
string function resolveConversationId( required GatewayMessage message, required IGateway sourceGateway ) {
var base = super.resolveConversationId( arguments.message, arguments.sourceGateway )
// Append a counter you bump when the user sends "/new"
return base & ":" & getFreshStartCounter( base )
}
}
Sub-agents benefit too: they now run under their parent's user and conversation, and AiBaseRequest gained a conversationId.
Provider settings that follow the docs
Two long-standing surprises are gone:
- Settings now reach every provider. Settings under both
providers.<slug>andproviders.<service name>apply, with the slug winning. Before, providers whose display name differs from their slug, such asopenai-compatibleanddocker, never received their settings. - Precedence is what the docs say. Options passed to
aiService()or in a profile now win overproviders.<name>.options, which only fill the gaps. AnddefaultParamsandproviders.<name>.paramsnow override a provider's built-in chat defaults, sodefaultParams.modelis finally sent.
There's also a handy addition: getConfig() now returns providerId, the registered id you can pass straight back to aiService() or aiChat(). The existing provider key is unchanged.
Fixes that make MCP servers more dependable
- STDIO servers keep stdout clean. Log lines no longer land between JSON-RPC messages. Console appenders move to stderr, so strict MCP clients stop choking.
- Notifications get no reply. A message without an
idnow gets no response. HTTP answers202 Acceptedwith no body. @mcpTooltools keep their parameters. Tools registered byscan()orscanClass()now list parameter names, types, required flags and@paramhints in their input schema.- Summaries stay with their conversation. Cache, file, session and JDBC memory no longer send one conversation's summary into another, a short conversation is no longer emptied by
summarize(), and the earlier summary survives a restart. Window and summary memory also keep their summary message when they trim. - JDBC memory under concurrency. Concurrent adds to one conversation no longer fail on primary key errors or overwrite each other. Writes are locked per datasource, table and scope. Two separate processes writing to the same conversation at the same instant can still lose a message.
- OAuth in web requests. The token request now sends its body correctly under CommandBox and the MiniServer.
Upgrading: a short checklist ✅
The memory changes are the ones to plan for:
- Gateway users: conversations saved under the old shared bucket won't be found under the new keys.
- JDBC memory: messages in the old single row remain under the memory's own key. Calls that name a user or conversation no longer return them.
- Window and summary memory: messages gathered under per-call ids before 3.8.0 live in the memory's own list and won't be returned for those ids.
- Provider settings: if you relied on a module-wide option overriding one passed in the call, flip it around. Call options now win.
- Custom
IMCPClientimplementations: add an optionalcontextargument tosend(). WithoutwithOAuth(), nothing else changes.
Get started
install-bx-module bx-ai
Resources
- Release notes: BoxLang AI 3.8.0
- BoxLang AI: ai.boxlang.io | GitHub
- BoxLang: boxlang.io | BoxLang docs
- Agent Skills: skills.boxlang.io
- Community: Ortus Community Slack
- Professional support and consulting: ortussolutions.com/services
Your agents can now act for the people they serve, and remember each of them separately. Go build something multi-user. 🚀
Add Your Comment