|
10 | 10 |
|
11 | 11 | from mcp_agent.app import MCPApp |
12 | 12 | from mcp_agent.server.app_server import create_mcp_server_for_app |
13 | | -from mcp_agent.config import Settings, LoggerSettings, \ |
14 | | - OAuthTokenStoreSettings, OAuthSettings, MCPAuthorizationServerSettings |
| 13 | +from mcp_agent.config import ( |
| 14 | + Settings, |
| 15 | + LoggerSettings, |
| 16 | + OAuthTokenStoreSettings, |
| 17 | + OAuthSettings, |
| 18 | + MCPAuthorizationServerSettings, |
| 19 | +) |
15 | 20 |
|
16 | 21 |
|
17 | | -auth_server = "https://auth.mcp-agent.com" # the MCP Agent Cloud auth server, or replace with your own |
| 22 | +auth_server = "https://auth.mcp-agent.com" # the MCP Agent Cloud auth server, or replace with your own |
18 | 23 | resource_server = "http://localhost:8000" # This server's URL |
19 | 24 |
|
20 | 25 | client_id = "<client id from registration.py>" |
21 | 26 | client_secret = "<client secret from registration.py>" |
22 | 27 |
|
23 | 28 | settings = Settings( |
24 | | - execution_engine="asyncio", |
25 | | - logger=LoggerSettings(level="info"), |
26 | | - authorization=MCPAuthorizationServerSettings( |
27 | | - enabled=True, |
28 | | - issuer_url=AnyHttpUrl(auth_server), |
29 | | - resource_server_url=AnyHttpUrl(resource_server), |
30 | | - client_id=client_id, |
31 | | - client_secret=client_secret, |
32 | | - required_scopes=["mcp"], |
33 | | - expected_audiences=[client_id], |
34 | | - ), |
35 | | - oauth=OAuthSettings( |
36 | | - callback_base_url=AnyHttpUrl(resource_server), |
37 | | - flow_timeout_seconds=300, |
38 | | - token_store=OAuthTokenStoreSettings(refresh_leeway_seconds=60), |
39 | | - ) |
40 | | - ) |
| 29 | + execution_engine="asyncio", |
| 30 | + logger=LoggerSettings(level="info"), |
| 31 | + authorization=MCPAuthorizationServerSettings( |
| 32 | + enabled=True, |
| 33 | + issuer_url=AnyHttpUrl(auth_server), |
| 34 | + resource_server_url=AnyHttpUrl(resource_server), |
| 35 | + client_id=client_id, |
| 36 | + client_secret=client_secret, |
| 37 | + required_scopes=["mcp"], |
| 38 | + expected_audiences=[client_id], |
| 39 | + ), |
| 40 | + oauth=OAuthSettings( |
| 41 | + callback_base_url=AnyHttpUrl(resource_server), |
| 42 | + flow_timeout_seconds=300, |
| 43 | + token_store=OAuthTokenStoreSettings(refresh_leeway_seconds=60), |
| 44 | + ), |
| 45 | +) |
41 | 46 |
|
42 | 47 |
|
43 | 48 | # Define the MCPApp instance. The server created for this app will advertise the |
@@ -66,6 +71,7 @@ async def hello(app_ctx: Optional[AppContext] = None) -> str: |
66 | 71 | else: |
67 | 72 | return "Hello, anonymous user!" |
68 | 73 |
|
| 74 | + |
69 | 75 | async def main(): |
70 | 76 | async with app.run() as agent_app: |
71 | 77 | # Log registered workflows and agent configurations |
|
0 commit comments