Skip to main content

Agent Registry – Microsoft Agent Framework

Integrate LumoAuth agent identity with the Microsoft Agent Framework to authenticate your agent, enforce capability-based authorization, and perform token exchange for secured MCP servers.

Prerequisites

Set the environment variables LUMOAUTH_URL, LUMOAUTH_TENANT, AGENT_CLIENT_ID, and AGENT_CLIENT_SECRET from your LumoAuth tenant portal. See Agent Registry for registration and credential setup.

Install

pip install agent-framework lumoauth

Python 3.10+ required.

Example

import asyncio
from typing import Annotated
from pydantic import Field
from agent_framework import Agent
from agent_framework.openai import OpenAIChatClient
from lumoauth import LumoAuthAgent

# 1. Authenticate the LumoAuth agent (client-credentials flow)
lumo = LumoAuthAgent()
lumo.authenticate()

# 2. Define tools guarded by LumoAuth capability checks
def search_company_documents(
query: Annotated[str, Field(description="The search query for company documents")],
) -> str:
"""Search internal company documents for the given query."""
if not lumo.has_capability("read:documents"):
return "Error: agent lacks 'read:documents' capability."
return f"Found 3 documents matching '{query}'"

def query_financial_mcp(
metric: Annotated[str, Field(description="The financial metric to retrieve")],
) -> str:
"""Query the secured financial metrics MCP server."""
if not lumo.has_capability("mcp:financial"):
return "Error: agent lacks 'mcp:financial' capability."
mcp_token = lumo.get_mcp_token("urn:mcp:financial-data")
if not mcp_token:
return "Error: failed to obtain MCP token."
return f"Retrieved {metric}: $1.2M (authenticated via MCP token exchange)"

# 3. Abort early if the agent's daily budget is exhausted
if lumo.is_budget_exhausted():
raise RuntimeError("Agent budget exhausted for today.")

# 4. Create the Microsoft Agent Framework agent with LumoAuth-guarded tools
agent = Agent(
client=OpenAIChatClient(),
name="Research Analyst",
instructions="You are a senior analyst. Use tools to search documents and query financial metrics.",
tools=[search_company_documents, query_financial_mcp],
)

# 5. Run the agent
async def main():
response = await agent.run(
"Search documents for Q3 performance, then query the financial MCP for EBITDA."
)
print(response)

if __name__ == "__main__":
asyncio.run(main())

How It Works

StepWhat happens
LumoAuthAgent()Reads credentials from env vars and initialises the client
lumo.authenticate()Performs OAuth 2.0 client-credentials flow, stores the access token
Plain functions in tools=[]Agent automatically wraps annotated functions as callable tools
lumo.has_capability(...)Checks the permission against LumoAuth before executing the tool
lumo.get_mcp_token(...)Exchanges the agent token for an MCP-specific token (RFC 8693)
await agent.run(...)Runs the agent and returns the final text response

Next Steps