Skip to content

Commit e4ba2ee

Browse files
committed
refactor: consolidate /mcp path into server_url
- Include /mcp in server_url defaults and CLI construction - Remove redundant string manipulation in token verifier initialization - Remove redundant string manipulation in auth settings configuration
1 parent 2bc3292 commit e4ba2ee

File tree

1 file changed

+4
-4
lines changed
  • examples/servers/simple-auth/mcp_simple_auth

1 file changed

+4
-4
lines changed

examples/servers/simple-auth/mcp_simple_auth/server.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class ResourceServerSettings(BaseSettings):
3232
# Server settings
3333
host: str = "localhost"
3434
port: int = 8001
35-
server_url: AnyHttpUrl = AnyHttpUrl("http://localhost:8001")
35+
server_url: AnyHttpUrl = AnyHttpUrl("http://localhost:8001/mcp")
3636

3737
# Authorization Server settings
3838
auth_server_url: AnyHttpUrl = AnyHttpUrl("http://localhost:9000")
@@ -63,7 +63,7 @@ def create_resource_server(settings: ResourceServerSettings) -> FastMCP:
6363
# Create token verifier for introspection with RFC 8707 resource validation
6464
token_verifier = IntrospectionTokenVerifier(
6565
introspection_endpoint=settings.auth_server_introspection_endpoint,
66-
server_url=f"{str(settings.server_url).rstrip('/')}/mcp",
66+
server_url=str(settings.server_url),
6767
validate_resource=settings.oauth_strict, # Only validate when --oauth-strict is set
6868
)
6969

@@ -79,7 +79,7 @@ def create_resource_server(settings: ResourceServerSettings) -> FastMCP:
7979
auth=AuthSettings(
8080
issuer_url=settings.auth_server_url,
8181
required_scopes=[settings.mcp_scope],
82-
resource_server_url=AnyHttpUrl(f"{str(settings.server_url).rstrip('/')}/mcp"),
82+
resource_server_url=settings.server_url,
8383
),
8484
)
8585

@@ -137,7 +137,7 @@ def main(port: int, auth_server: str, transport: Literal["sse", "streamable-http
137137

138138
# Create settings
139139
host = "localhost"
140-
server_url = f"http://{host}:{port}"
140+
server_url = f"http://{host}:{port}/mcp"
141141
settings = ResourceServerSettings(
142142
host=host,
143143
port=port,

0 commit comments

Comments
 (0)