diff --git a/en/asgardeo/docs/quick-starts/mcp-auth-server.md b/en/asgardeo/docs/quick-starts/mcp-auth-server.md index b99613aa47..35130f340d 100644 --- a/en/asgardeo/docs/quick-starts/mcp-auth-server.md +++ b/en/asgardeo/docs/quick-starts/mcp-auth-server.md @@ -5,7 +5,7 @@ template: templates/quick-start.html + +{% include "../../../../includes/quick-starts/agent-auth-py.md" %} diff --git a/en/identity-server/7.2.0/docs/quick-starts/agent-auth-ts.md b/en/identity-server/7.2.0/docs/quick-starts/agent-auth-ts.md new file mode 100644 index 0000000000..7dba326c4e --- /dev/null +++ b/en/identity-server/7.2.0/docs/quick-starts/agent-auth-ts.md @@ -0,0 +1,25 @@ +--- +template: templates/quick-start.html +--- + + + +{% include "../../../../includes/quick-starts/agent-auth-ts.md" %} diff --git a/en/identity-server/7.2.0/docs/quick-starts/mcp-auth-server-py.md b/en/identity-server/7.2.0/docs/quick-starts/mcp-auth-server-py.md new file mode 100644 index 0000000000..84f482c0b7 --- /dev/null +++ b/en/identity-server/7.2.0/docs/quick-starts/mcp-auth-server-py.md @@ -0,0 +1,23 @@ +--- +template: templates/quick-start.html +--- + + + +{% include "../../../../includes/quick-starts/mcp-auth-server-py.md" %} diff --git a/en/identity-server/7.2.0/docs/quick-starts/mcp-auth-server.md b/en/identity-server/7.2.0/docs/quick-starts/mcp-auth-server.md new file mode 100644 index 0000000000..989f5a6fe0 --- /dev/null +++ b/en/identity-server/7.2.0/docs/quick-starts/mcp-auth-server.md @@ -0,0 +1,24 @@ +--- +template: templates/quick-start.html +--- + + + +{% include "../../../../includes/quick-starts/mcp-auth-server.md" %} diff --git a/en/identity-server/7.2.0/mkdocs.yml b/en/identity-server/7.2.0/mkdocs.yml index d0f1971edf..9563368741 100644 --- a/en/identity-server/7.2.0/mkdocs.yml +++ b/en/identity-server/7.2.0/mkdocs.yml @@ -575,6 +575,12 @@ nav: - OIDC Java EE: get-started/try-samples/qsg-oidc-webapp-java-ee.md - SAML Java EE: get-started/try-samples/qsg-saml-webapp-java-ee.md - WS-Federation: get-started/try-samples/ws-federation-webapp.md + - Secure MCP Servers: + - TypeScript: quick-starts/mcp-auth-server.md + - Python: quick-starts/mcp-auth-server-py.md + - Secure Your AI Agents: + - Python: quick-starts/agent-auth-py.md + - TypeScript: quick-starts/agent-auth-ts.md - Subscribe to AI features: get-started/subscribe-to-ai-features.md - About this release: get-started/about-this-release.md - Guides: diff --git a/en/identity-server/next/docs/quick-starts/agent-auth-py.md b/en/identity-server/next/docs/quick-starts/agent-auth-py.md new file mode 100644 index 0000000000..4f6038df05 --- /dev/null +++ b/en/identity-server/next/docs/quick-starts/agent-auth-py.md @@ -0,0 +1,25 @@ +--- +template: templates/quick-start.html +--- + + + +{% include "../../../../includes/quick-starts/agent-auth-py.md" %} diff --git a/en/identity-server/next/docs/quick-starts/agent-auth-ts.md b/en/identity-server/next/docs/quick-starts/agent-auth-ts.md new file mode 100644 index 0000000000..7ab88705c9 --- /dev/null +++ b/en/identity-server/next/docs/quick-starts/agent-auth-ts.md @@ -0,0 +1,25 @@ +--- +template: templates/quick-start.html +--- + + + +{% include "../../../../includes/quick-starts/agent-auth-ts.md" %} diff --git a/en/identity-server/next/docs/quick-starts/mcp-auth-server-py.md b/en/identity-server/next/docs/quick-starts/mcp-auth-server-py.md new file mode 100644 index 0000000000..84f482c0b7 --- /dev/null +++ b/en/identity-server/next/docs/quick-starts/mcp-auth-server-py.md @@ -0,0 +1,23 @@ +--- +template: templates/quick-start.html +--- + + + +{% include "../../../../includes/quick-starts/mcp-auth-server-py.md" %} diff --git a/en/identity-server/next/docs/quick-starts/mcp-auth-server.md b/en/identity-server/next/docs/quick-starts/mcp-auth-server.md new file mode 100644 index 0000000000..989f5a6fe0 --- /dev/null +++ b/en/identity-server/next/docs/quick-starts/mcp-auth-server.md @@ -0,0 +1,24 @@ +--- +template: templates/quick-start.html +--- + + + +{% include "../../../../includes/quick-starts/mcp-auth-server.md" %} diff --git a/en/identity-server/next/mkdocs.yml b/en/identity-server/next/mkdocs.yml index aa3d5034a8..ad3813835e 100644 --- a/en/identity-server/next/mkdocs.yml +++ b/en/identity-server/next/mkdocs.yml @@ -584,6 +584,12 @@ nav: - OIDC Java EE: get-started/try-samples/qsg-oidc-webapp-java-ee.md - SAML Java EE: get-started/try-samples/qsg-saml-webapp-java-ee.md - WS-Federation: get-started/try-samples/ws-federation-webapp.md + - Secure MCP Servers: + - TypeScript: quick-starts/mcp-auth-server.md + - Python: quick-starts/mcp-auth-server-py.md + - Secure Your AI Agents: + - Python: quick-starts/agent-auth-py.md + - TypeScript: quick-starts/agent-auth-ts.md - Subscribe to AI features: get-started/subscribe-to-ai-features.md - About this release: get-started/about-this-release.md - Guides: diff --git a/en/includes/quick-starts/agent-auth-py.md b/en/includes/quick-starts/agent-auth-py.md index 121526af89..5ee073518c 100644 --- a/en/includes/quick-starts/agent-auth-py.md +++ b/en/includes/quick-starts/agent-auth-py.md @@ -130,13 +130,19 @@ Create `main.py` that implements an AI agent which first obtains a valid access # Load environment variables from .env file load_dotenv() - + {% if product_name == "Asgardeo" %} ASGARDEO_CONFIG = AsgardeoConfig( base_url=os.getenv("ASGARDEO_BASE_URL"), client_id=os.getenv("CLIENT_ID"), redirect_uri=os.getenv("REDIRECT_URI") ) - + {% else %} + IDENTITY_SERVER_CONFIG = AsgardeoConfig( + base_url=os.getenv("IDENTITY_SERVER_BASE_URL"), + client_id=os.getenv("CLIENT_ID"), + redirect_uri=os.getenv("REDIRECT_URI") + ) + {% endif %} AGENT_CONFIG = AgentConfig( agent_id=os.getenv("AGENT_ID"), agent_secret=os.getenv("AGENT_SECRET") @@ -144,7 +150,7 @@ Create `main.py` that implements an AI agent which first obtains a valid access async def main(): # Scenario 1: AI agent acting on its own using its own credentials to authenticate - async with AgentAuthManager(ASGARDEO_CONFIG, AGENT_CONFIG) as auth_manager: + async with AgentAuthManager({% if product_name == "Asgardeo" %}ASGARDEO_CONFIG{% else %}IDENTITY_SERVER_CONFIG{% endif %}, AGENT_CONFIG) as auth_manager: # Get agent token agent_token = await auth_manager.get_agent_token(["openid"]) @@ -205,20 +211,26 @@ Create `main.py` that implements an AI agent which first obtains a valid access # Load environment variables from .env file load_dotenv() - + {% if product_name == "Asgardeo" %} ASGARDEO_CONFIG = AsgardeoConfig( base_url=os.getenv("ASGARDEO_BASE_URL"), client_id=os.getenv("CLIENT_ID"), redirect_uri=os.getenv("REDIRECT_URI") ) - + {% else %} + IDENTITY_SERVER_CONFIG = AsgardeoConfig( + base_url=os.getenv("IDENTITY_SERVER_BASE_URL"), + client_id=os.getenv("CLIENT_ID"), + redirect_uri=os.getenv("REDIRECT_URI") + ) + {% endif %} AGENT_CONFIG = AgentConfig( agent_id=os.getenv("AGENT_ID"), agent_secret=os.getenv("AGENT_SECRET") ) async def build_toolset(): - async with AgentAuthManager(ASGARDEO_CONFIG, AGENT_CONFIG) as auth_manager: + async with AgentAuthManager({% if product_name == "Asgardeo" %}ASGARDEO_CONFIG{% else %}IDENTITY_SERVER_CONFIG{% endif %}, AGENT_CONFIG) as auth_manager: # Get agent token agent_token = await auth_manager.get_agent_token(["openid"]) @@ -292,13 +304,19 @@ Create `main.py` that implements an AI agent which first obtains a valid access # Load environment variables from .env file load_dotenv() - + {% if product_name == "Asgardeo" %} ASGARDEO_CONFIG = AsgardeoConfig( base_url=os.getenv("ASGARDEO_BASE_URL"), client_id=os.getenv("CLIENT_ID"), redirect_uri=os.getenv("REDIRECT_URI") ) - + {% else %} + IDENTITY_SERVER_CONFIG = AsgardeoConfig( + base_url=os.getenv("IDENTITY_SERVER_BASE_URL"), + client_id=os.getenv("CLIENT_ID"), + redirect_uri=os.getenv("REDIRECT_URI") + ) + {% endif %} AGENT_CONFIG = AgentConfig( agent_id=os.getenv("AGENT_ID"), agent_secret=os.getenv("AGENT_SECRET") @@ -306,7 +324,7 @@ Create `main.py` that implements an AI agent which first obtains a valid access async def get_agent_token(): # Asynchronously fetches the agent token from Asgardeo. - async with AgentAuthManager(ASGARDEO_CONFIG, AGENT_CONFIG) as auth_manager: + async with AgentAuthManager({% if product_name == "Asgardeo" %}ASGARDEO_CONFIG{% else %}IDENTITY_SERVER_CONFIG{% endif %}, AGENT_CONFIG) as auth_manager: return await auth_manager.get_agent_token(["openid"]) def main(): @@ -368,13 +386,19 @@ Create `main.py` that implements an AI agent which first obtains a valid access # Load environment variables from .env file load_dotenv() - + {% if product_name == "Asgardeo" %} ASGARDEO_CONFIG = AsgardeoConfig( base_url=os.getenv("ASGARDEO_BASE_URL"), client_id=os.getenv("CLIENT_ID"), redirect_uri=os.getenv("REDIRECT_URI") ) - + {% else %} + IDENTITY_SERVER_CONFIG = AsgardeoConfig( + base_url=os.getenv("IDENTITY_SERVER_BASE_URL"), + client_id=os.getenv("CLIENT_ID"), + redirect_uri=os.getenv("REDIRECT_URI") + ) + {% endif %} AGENT_CONFIG = AgentConfig( agent_id=os.getenv("AGENT_ID"), agent_secret=os.getenv("AGENT_SECRET") @@ -393,7 +417,7 @@ Create `main.py` that implements an AI agent which first obtains a valid access async def main(): - async with AgentAuthManager(ASGARDEO_CONFIG, AGENT_CONFIG) as auth_manager: + async with AgentAuthManager({% if product_name == "Asgardeo" %}ASGARDEO_CONFIG{% else %}IDENTITY_SERVER_CONFIG{% endif %}, AGENT_CONFIG) as auth_manager: agent_token = await auth_manager.get_agent_token(["openid"]) google_key = os.getenv("GOOGLE_API_KEY", "") @@ -429,6 +453,7 @@ Create `main.py` that implements an AI agent which first obtains a valid access Add environment configuration by creating a `.env` file at the project root to hold the {{ product_name }} configuration: ```properties title=".env" +{% if product_name == "Asgardeo" %} # Asgardeo OAuth2 Configuration ASGARDEO_BASE_URL=https://api.asgardeo.io/t/ CLIENT_ID= @@ -437,6 +462,16 @@ REDIRECT_URI=http://localhost:6274/oauth/callback # Asgardeo Agent Credentials AGENT_ID= AGENT_SECRET= +{% else %} +# Identity Server OAuth2 Configuration +IDENTITY_SERVER_BASE_URL=https://localhost:9443/t/ +CLIENT_ID= +REDIRECT_URI=http://localhost:6274/oauth/callback + +# Identity Server Agent Credentials +AGENT_ID= +AGENT_SECRET= +{% endif %} # Google Gemini API Key GOOGLE_API_KEY= @@ -451,7 +486,7 @@ MODEL_NAME="gemini-2.5-flash" !!! Important - Replace ``, ``and the redirect URL with the values obtained from the {{ product_name }} console. - The tenant name is visible in the console URL path (e.g., `https://console.asgardeo.io/t/`), and the `client ID` can be found in the application's **Protocol** tab. + The tenant name is visible in the console URL path (e.g., {% if product_name == "Asgardeo" %}`https://console.asgardeo.io/t/` {% else %}`https://localhost:9443/t/`{% endif %}), and the `client ID` can be found in the application's **Protocol** tab. - Add the `Agent ID` and `Agent Secret` from the [Agent Registration](#register-an-ai-agent) step. @@ -664,23 +699,28 @@ Here is the updated implementation: # Load environment variables from .env file load_dotenv() - + {% if product_name == "Asgardeo" %} ASGARDEO_CONFIG = AsgardeoConfig( base_url=os.getenv("ASGARDEO_BASE_URL"), client_id=os.getenv("CLIENT_ID"), redirect_uri=os.getenv("REDIRECT_URI") ) - + {% else %} + IDENTITY_SERVER_CONFIG = AsgardeoConfig( + base_url=os.getenv("IDENTITY_SERVER_BASE_URL"), + client_id=os.getenv("CLIENT_ID"), + redirect_uri=os.getenv("REDIRECT_URI") + ) + {% endif %} AGENT_CONFIG = AgentConfig( agent_id=os.getenv("AGENT_ID"), agent_secret=os.getenv("AGENT_SECRET") ) - async def main(): # Perform OBO flow (authenticating on behalf of the user) - async with AgentAuthManager(ASGARDEO_CONFIG, AGENT_CONFIG) as auth_manager: + async with AgentAuthManager({% if product_name == "Asgardeo" %}ASGARDEO_CONFIG{% else %}IDENTITY_SERVER_CONFIG{% endif %}, AGENT_CONFIG) as auth_manager: # Get agent token agent_token = await auth_manager.get_agent_token(["openid"]) @@ -767,13 +807,19 @@ Here is the updated implementation: # Load environment variables from .env file load_dotenv() - + {% if product_name == "Asgardeo" %} ASGARDEO_CONFIG = AsgardeoConfig( base_url=os.getenv("ASGARDEO_BASE_URL"), client_id=os.getenv("CLIENT_ID"), redirect_uri=os.getenv("REDIRECT_URI") ) - + {% else %} + IDENTITY_SERVER_CONFIG = AsgardeoConfig( + base_url=os.getenv("IDENTITY_SERVER_BASE_URL"), + client_id=os.getenv("CLIENT_ID"), + redirect_uri=os.getenv("REDIRECT_URI") + ) + {% endif %} AGENT_CONFIG = AgentConfig( agent_id=os.getenv("AGENT_ID"), agent_secret=os.getenv("AGENT_SECRET") @@ -781,7 +827,7 @@ Here is the updated implementation: # Perform OBO flow (authenticating on behalf of the user) async def build_toolset(): - async with AgentAuthManager(ASGARDEO_CONFIG, AGENT_CONFIG) as auth_manager: + async with AgentAuthManager({% if product_name == "Asgardeo" %}ASGARDEO_CONFIG{% else %}IDENTITY_SERVER_CONFIG{% endif %}, AGENT_CONFIG) as auth_manager: # Get agent token agent_token = await auth_manager.get_agent_token(["openid"]) @@ -896,17 +942,25 @@ Here is the updated implementation: async def get_obo_token(): # Handles the OAuth/OBO flow to get the user token. + {% if product_name == "Asgardeo" %} ASGARDEO_CONFIG = AsgardeoConfig( base_url=os.getenv("ASGARDEO_BASE_URL"), client_id=os.getenv("CLIENT_ID"), redirect_uri=os.getenv("REDIRECT_URI") ) + {% else %} + IDENTITY_SERVER_CONFIG = AsgardeoConfig( + base_url=os.getenv("IDENTITY_SERVER_BASE_URL"), + client_id=os.getenv("CLIENT_ID"), + redirect_uri=os.getenv("REDIRECT_URI") + ) + {% endif %} AGENT_CONFIG = AgentConfig( agent_id=os.getenv("AGENT_ID"), agent_secret=os.getenv("AGENT_SECRET") ) - async with AgentAuthManager(ASGARDEO_CONFIG, AGENT_CONFIG) as auth_manager: + async with AgentAuthManager({% if product_name == "Asgardeo" %}ASGARDEO_CONFIG{% else %}IDENTITY_SERVER_CONFIG{% endif %}, AGENT_CONFIG) as auth_manager: agent_token = await auth_manager.get_agent_token(["openid", "email"]) auth_url, state, code_verifier = auth_manager.get_authorization_url_with_pkce(["openid", "email"]) @@ -1007,13 +1061,19 @@ Here is the updated implementation: # Load environment variables from .env file load_dotenv() - + {% if product_name == "Asgardeo" %} ASGARDEO_CONFIG = AsgardeoConfig( base_url=os.getenv("ASGARDEO_BASE_URL"), client_id=os.getenv("CLIENT_ID"), redirect_uri=os.getenv("REDIRECT_URI") ) - + {% else %} + IDENTITY_SERVER_CONFIG = AsgardeoConfig( + base_url=os.getenv("IDENTITY_SERVER_BASE_URL"), + client_id=os.getenv("CLIENT_ID"), + redirect_uri=os.getenv("REDIRECT_URI") + ) + {% endif %} AGENT_CONFIG = AgentConfig( agent_id=os.getenv("AGENT_ID"), agent_secret=os.getenv("AGENT_SECRET") @@ -1035,7 +1095,7 @@ Here is the updated implementation: async def main(): - async with AgentAuthManager(ASGARDEO_CONFIG, AGENT_CONFIG) as auth_manager: + async with AgentAuthManager({% if product_name == "Asgardeo" %}ASGARDEO_CONFIG{% else %}IDENTITY_SERVER_CONFIG{% endif %}, AGENT_CONFIG) as auth_manager: agent_token = await auth_manager.get_agent_token(["openid", "email"]) auth_url, state, code_verifier = auth_manager.get_authorization_url_with_pkce(["openid", "email"]) diff --git a/en/includes/quick-starts/agent-auth-ts.md b/en/includes/quick-starts/agent-auth-ts.md index 007402b9b0..d1b1cd255d 100644 --- a/en/includes/quick-starts/agent-auth-ts.md +++ b/en/includes/quick-starts/agent-auth-ts.md @@ -133,13 +133,19 @@ Create `agent.ts` that implements an AI agent which first obtains a valid access // Load environment variables from .env file dotenv.config(); - + {% if product_name == "Asgardeo" %} const asgardeoConfig = { afterSignInUrl: process.env.REDIRECT_URI || "", clientId: process.env.CLIENT_ID || "", baseUrl: process.env.ASGARDEO_BASE_URL || "", }; - + {% else %} + const identityServerConfig = { + afterSignInUrl: process.env.REDIRECT_URI || "", + clientId: process.env.CLIENT_ID || "", + baseUrl: process.env.IDENTITY_SERVER_BASE_URL || "", + }; + {% endif %} const agentConfig = { agentID: process.env.AGENT_ID || "", agentSecret: process.env.AGENT_SECRET || "", @@ -151,8 +157,13 @@ Create `agent.ts` that implements an AI agent which first obtains a valid access }); async function runAgent() { + {% if product_name == "Asgardeo" %} const asgardeoJavaScriptClient = new AsgardeoJavaScriptClient(asgardeoConfig); const agentToken = await asgardeoJavaScriptClient.getAgentToken(agentConfig); + {% else %} + const identityServerJavaScriptClient = new AsgardeoJavaScriptClient(identityServerConfig); + const agentToken = await identityServerJavaScriptClient.getAgentToken(agentConfig); + {% endif %} const client = new MultiServerMCPClient({ math: { @@ -215,13 +226,19 @@ Create `agent.ts` that implements an AI agent which first obtains a valid access // Load environment variables from .env file dotenv.config(); - + {% if product_name == "Asgardeo" %} const asgardeoConfig = { afterSignInUrl: process.env.REDIRECT_URI, clientId: process.env.CLIENT_ID, baseUrl: process.env.ASGARDEO_BASE_URL, }; - + {% else %} + const identityServerConfig = { + afterSignInUrl: process.env.REDIRECT_URI, + clientId: process.env.CLIENT_ID, + baseUrl: process.env.IDENTITY_SERVER_BASE_URL, + }; + {% endif %} const agentConfig = { agentID: process.env.AGENT_ID, agentSecret: process.env.AGENT_SECRET, @@ -231,9 +248,14 @@ Create `agent.ts` that implements an AI agent which first obtains a valid access async function runAgent() { silenceADK(); + {% if product_name == "Asgardeo" %} const asgardeoJavaScriptClient = new AsgardeoJavaScriptClient(asgardeoConfig); const agentToken = await asgardeoJavaScriptClient.getAgentToken(agentConfig); - + {% else %} + const identityServerJavaScriptClient = new AsgardeoJavaScriptClient(identityServerConfig); + const agentToken = await identityServerJavaScriptClient.getAgentToken(agentConfig); + {% endif %} + const rootAgent = new LlmAgent({ name: "example_agent", model: process.env.MODEL_NAME || "gemini-2.5-flash", @@ -339,13 +361,19 @@ Create `agent.ts` that implements an AI agent which first obtains a valid access // Load environment variables from .env file dotenv.config(); - + {% if product_name == "Asgardeo" %} const asgardeoConfig = { afterSignInUrl: process.env.REDIRECT_URI || "", clientId: process.env.CLIENT_ID || "", baseUrl: process.env.ASGARDEO_BASE_URL || "", }; - + {% else %} + const identityServerConfig = { + afterSignInUrl: process.env.REDIRECT_URI || "", + clientId: process.env.CLIENT_ID || "", + baseUrl: process.env.IDENTITY_SERVER_BASE_URL || "", + }; + {% endif %} const agentConfig = { agentID: process.env.AGENT_ID || "", agentSecret: process.env.AGENT_SECRET || "", @@ -400,8 +428,13 @@ Create `agent.ts` that implements an AI agent which first obtains a valid access } async function runAgent() { + {% if product_name == "Asgardeo" %} const asgardeoJavaScriptClient = new AsgardeoJavaScriptClient(asgardeoConfig); const agentToken = await asgardeoJavaScriptClient.getAgentToken(agentConfig); + {% else %} + const identityServerJavaScriptClient = new AsgardeoJavaScriptClient(identityServerConfig); + const agentToken = await identityServerJavaScriptClient.getAgentToken(agentConfig); + {% endif %} process.env.GOOGLE_GENERATIVE_AI_API_KEY = process.env.GOOGLE_API_KEY || ""; @@ -458,6 +491,7 @@ Create `agent.ts` that implements an AI agent which first obtains a valid access Add environment configuration by creating a `.env` file at the project root to hold the {{ product_name }} configuration: ```properties title=".env" +{% if product_name == "Asgardeo" %} # Asgardeo OAuth2 Configuration ASGARDEO_BASE_URL=https://api.asgardeo.io/t/ CLIENT_ID= @@ -466,6 +500,16 @@ REDIRECT_URI=http://localhost:3001/callback # Asgardeo Agent Credentials AGENT_ID= AGENT_SECRET= +{% else %} +# Identity Server OAuth2 Configuration +IDENTITY_SERVER_BASE_URL=https://localhost:9443/t/ +CLIENT_ID= +REDIRECT_URI=http://localhost:3001/callback + +# Identity Server Agent Credentials +AGENT_ID= +AGENT_SECRET= +{% endif %} # Google Gemini API Key GOOGLE_API_KEY= @@ -478,9 +522,13 @@ MODEL_NAME="gemini-2.5-flash" ``` !!! Important - + {% if product_name == "Asgardeo" %} - Replace `` and `` with the values obtained from the {{ product_name }} console. - The organization name is visible in the console URL path (e.g., `https://console.asgardeo.io/t/`), and the `client ID` can be found in the application's **Protocol** tab. + The organization name is visible in the console URL path (e.g., `https://console.asgardeo.io/t/`), and the `client ID` can be found in the application's **Protocol** tab. + {% else %} + - Replace `` and `` with the values obtained from the {{ product_name }} console. + The tenant name is visible in the console URL path (e.g., `https://localhost:9443/t/`), and the `client ID` can be found in the application's **Protocol** tab. + {% endif %} - Add the `` and `` from the [Agent Registration](#register-an-ai-agent) step. @@ -590,13 +638,19 @@ Here is the updated implementation: // Load environment variables from .env file dotenv.config(); - + {% if product_name == "Asgardeo" %} const asgardeoConfig = { afterSignInUrl: process.env.REDIRECT_URI || "", clientId: process.env.CLIENT_ID || "", baseUrl: process.env.ASGARDEO_BASE_URL || "", }; - + {% else %} + const identityServerConfig = { + afterSignInUrl: process.env.REDIRECT_URI || "", + clientId: process.env.CLIENT_ID || "", + baseUrl: process.env.IDENTITY_SERVER_BASE_URL || "", + }; + {% endif %} const agentConfig = { agentID: process.env.AGENT_ID || "", agentSecret: process.env.AGENT_SECRET || "", @@ -608,9 +662,14 @@ Here is the updated implementation: }); async function runAgent() { + {% if product_name == "Asgardeo" %} const asgardeoJavaScriptClient = new AsgardeoJavaScriptClient(asgardeoConfig); - const authURL = await asgardeoJavaScriptClient.getOBOSignInURL(agentConfig); + {% else %} + const identityServerJavaScriptClient = new AsgardeoJavaScriptClient(identityServerConfig ); + const authURL = await identityServerJavaScriptClient.getOBOSignInURL(agentConfig); + {% endif %} + console.log("Opening authentication URL in your browser..."); await open(authURL); @@ -659,8 +718,11 @@ Here is the updated implementation: }); authCodeResponse = await authCodePromise; - + {% if product_name == "Asgardeo" %} const oboToken = await asgardeoJavaScriptClient.getOBOToken(agentConfig, authCodeResponse); + {% else %} + const oboToken = await identityServerJavaScriptClient.getOBOToken(agentConfig, authCodeResponse); + {% endif %} const client = new MultiServerMCPClient({ math: { @@ -737,12 +799,19 @@ Here is the updated implementation: // Load environment variables from .env file dotenv.config(); - + {% if product_name == "Asgardeo" %} const asgardeoConfig = { afterSignInUrl: process.env.REDIRECT_URI || "", clientId: process.env.CLIENT_ID || "", baseUrl: process.env.ASGARDEO_BASE_URL || "", }; + {% else %} + const identityServerConfig = { + afterSignInUrl: process.env.REDIRECT_URI || "", + clientId: process.env.CLIENT_ID || "", + baseUrl: process.env.IDENTITY_SERVER_BASE_URL || "", + }; + {% endif %} const agentConfig = { agentID: process.env.AGENT_ID || "", @@ -753,9 +822,13 @@ Here is the updated implementation: async function runAgent() { silenceADK(); + {% if product_name == "Asgardeo" %} const asgardeoJavaScriptClient = new AsgardeoJavaScriptClient(asgardeoConfig); - const authURL = await asgardeoJavaScriptClient.getOBOSignInURL(agentConfig); + {% else %} + const identityServerJavaScriptClient = new AsgardeoJavaScriptClient(identityServerConfig); + const authURL = await identityServerJavaScriptClient.getOBOSignInURL(agentConfig); + {% endif %} console.log("Opening authentication URL in your browser..."); await open(authURL); @@ -804,9 +877,11 @@ Here is the updated implementation: }); authCodeResponse = await authCodePromise; - + {% if product_name == "Asgardeo" %} const oboToken = await asgardeoJavaScriptClient.getOBOToken(agentConfig, authCodeResponse); - + {% else %} + const oboToken = await identityServerJavaScriptClient.getOBOToken(agentConfig, authCodeResponse); + {% endif %} const rootAgent = new LlmAgent({ name: "example_agent", model: process.env.MODEL_NAME || "gemini-2.5-flash", @@ -921,12 +996,19 @@ Here is the updated implementation: const callbackPort = Number( redirectURL.port || (redirectURL.protocol === "https:" ? 443 : 80) ); - + {% if product_name == "Asgardeo" %} const asgardeoConfig = { afterSignInUrl: process.env.REDIRECT_URI || "", clientId: process.env.CLIENT_ID || "", baseUrl: process.env.ASGARDEO_BASE_URL || "", }; + {% else %} + const identityServerConfig = { + afterSignInUrl: process.env.REDIRECT_URI || "", + clientId: process.env.CLIENT_ID || "", + baseUrl: process.env.IDENTITY_SERVER_BASE_URL || "", + }; + {% endif %} const agentConfig = { agentID: process.env.AGENT_ID || "", @@ -981,9 +1063,13 @@ Here is the updated implementation: } async function runAgent() { + {% if product_name == "Asgardeo" %} const asgardeoJavaScriptClient = new AsgardeoJavaScriptClient(asgardeoConfig); - const authURL = await asgardeoJavaScriptClient.getOBOSignInURL(agentConfig); + {% else %} + const identityServerJavaScriptClient = new AsgardeoJavaScriptClient(identityServerConfig); + const authURL = await identityServerJavaScriptClient.getOBOSignInURL(agentConfig); + {% endif %} console.log("Opening authentication URL in your browser..."); await open(authURL); @@ -1091,6 +1177,7 @@ Add environment configuration by creating a `.env` file at the project root to h ```properties title=".env" # Asgardeo OAuth2 Configuration +{% if product_name == "Asgardeo" %} ASGARDEO_BASE_URL=https://api.asgardeo.io/t/ CLIENT_ID= REDIRECT_URI=http://localhost:3001/callback @@ -1098,6 +1185,15 @@ REDIRECT_URI=http://localhost:3001/callback # Asgardeo Agent Credentials AGENT_ID= AGENT_SECRET= +{% else %} +IDENTITY_SERVER_BASE_URL=https://localhost:9443/t/ +CLIENT_ID= +REDIRECT_URI=http://localhost:3001/callback + +# Identity Server Agent Credentials +AGENT_ID= +AGENT_SECRET= +{% endif %} # Google Gemini API Key GOOGLE_API_KEY= diff --git a/en/includes/quick-starts/mcp-auth-server-py.md b/en/includes/quick-starts/mcp-auth-server-py.md index 832c2065e4..131eb82a70 100644 --- a/en/includes/quick-starts/mcp-auth-server-py.md +++ b/en/includes/quick-starts/mcp-auth-server-py.md @@ -118,16 +118,28 @@ Stop the running server before continuing. Add environment configuration by creating a `.env` file at the project root to hold the {{ product_name }} configuration: +{% if product_name == "Asgardeo" %} + ```properties title=".env" AUTH_ISSUER=https://api.asgardeo.io/t//oauth2/token CLIENT_ID= JWKS_URL=https://api.asgardeo.io/t//oauth2/jwks ``` +{% else %} + +```properties title=".env" +AUTH_ISSUER=https://localhost:9443/t//oauth2/token +CLIENT_ID= +JWKS_URL=https://localhost:9443/t//oauth2/jwks +``` + +{% endif %} + !!! Important Replace `` and `` with the values obtained from the {{ product_name }} console. - The tenant name is visible in the console URL path (e.g., `https://console.asgardeo.io/t/`), and the client ID is found in the application's **Protocol** tab. + The tenant name is visible in the console URL path {% if product_name == "Asgardeo" %}(e.g., `https://console.asgardeo.io/t/`) {% else %} (e.g., `https://localhost:9443/t/`) {% endif %}, and the client ID is found in the application's **Protocol** tab. Create a `jwt_validator.py` file in the project directory using the implementation below. diff --git a/en/includes/quick-starts/mcp-auth-server.md b/en/includes/quick-starts/mcp-auth-server.md index 5c55e9b9bf..38e7f5375d 100644 --- a/en/includes/quick-starts/mcp-auth-server.md +++ b/en/includes/quick-starts/mcp-auth-server.md @@ -229,11 +229,20 @@ Stop the dev server and install the Asgardeo MCP Auth SDK. Create '.env' file and add the base URL of your {{product_name}} organization as given below. +{% if product_name == "Asgardeo" %} + ```env BASE_URL=https://api.asgardeo.io/t/ +``` + +{% else %} +```env +BASE_URL=https://localhost:9443/t/ ``` +{% endif %} + Update `server.ts` to integrate the Asgardeo middleware. This adds: - Initialization of `McpAuthServer`.