Blog

Luis Majano

December 01, 2026

Spread the word


Share your thoughts

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:

The MCP OAuth flow in BoxLang AI 3.8.0: discovery, sign-in with PKCE, callback, bearer token, refresh.

Here is what happens under the hood:

  1. Discovery. The client reads the server's Protected Resource Metadata, then the authorization server's metadata.
  2. A client ID. Use one you registered, a Client ID Metadata Document, or Dynamic Client Registration. The registration is stored, so it happens once.
  3. Sign-in with PKCE (S256). startAuthorization() returns the sign-in address, including the resource parameter so the token is for that MCP server.
  4. Callback. completeAuthorization() checks the state and the iss of the callback, then trades the code for tokens.
  5. Every request carries Authorization: Bearer. Tokens are refreshed before they expire, and a 401 triggers 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:

  • discoverySubject covers 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:

ReasonMeans
no_tokenNo tokens, or they were refused on refresh
unauthorizedThe server answered 401 even for a fresh token
insufficient_scopeThe 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:

StoreWhere tokens live
cache (default)A BoxLang cache. In memory by default, durable with a Redis or file-backed cache
fileOne JSON file per record
jdbcA 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.

Before: one shared memory bucket. After: a separate memory scope per user and conversation.

What changed:

  • Window and summary memory now keep a separate message list per user and conversation. window is the default memory, so an agent built with aiAgent() 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 a userId when the platform names the sender). A conversation is the chat namespaced by its gateway, such as telegram:42, plus the platform thread when there is one, such as telegram: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> and providers.<service name> apply, with the slug winning. Before, providers whose display name differs from their slug, such as openai-compatible and docker, never received their settings.
  • Precedence is what the docs say. Options passed to aiService() or in a profile now win over providers.<name>.options, which only fill the gaps. And defaultParams and providers.<name>.params now override a provider's built-in chat defaults, so defaultParams.model is 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 id now gets no response. HTTP answers 202 Accepted with no body.
  • @mcpTool tools keep their parameters. Tools registered by scan() or scanClass() now list parameter names, types, required flags and @param hints 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 IMCPClient implementations: add an optional context argument to send(). Without withOAuth(), nothing else changes.

Get started

install-bx-module bx-ai

Resources

Your agents can now act for the people they serve, and remember each of them separately. Go build something multi-user. 🚀

Add Your Comment

Recent Entries

November 2026 Roundup: What’s New Across Ortus Solutions & BoxLang

November 2026 Roundup: What’s New Across Ortus Solutions & BoxLang

From BoxLang 1.19 and BoxLang AI 3.7 to new migration tooling, QA insights, hands-on AI development with students, and community events around the world, this month continued to show how the different parts of our ecosystem connect.

We also officially launched Into the Box 2027 in Orlando and opened our Ortus Year-End Offers, giving teams new ways to start planning their development, modernization, and training goals for the year ahead.

Here’s everything you may have missed in November.

Victor Campos
Victor Campos
December 01, 2026
Is Your CFML Upgrade Overdue? See Where BoxLang and BxLens Can Help

Is Your CFML Upgrade Overdue? See Where BoxLang and BxLens Can Help

An overdue ColdFusion or Lucee upgrade gets easier to scope when you know which workflows could be affected. See how BoxLang helps you assess a migration and how BxLens helps you investigate slow requests and recurring errors.

Maria Jose Herrera
Maria Jose Herrera
November 30, 2026