Update echo_server.py
Browse files- echo_server.py +0 -26
echo_server.py
CHANGED
@@ -5,29 +5,3 @@ mcp = FastMCP(name="EchoServer", stateless_http=True)
|
|
5 |
@mcp.tool(description="A simple echo tool")
|
6 |
def echo(message: str) -> str:
|
7 |
return f"Echo: {message}"
|
8 |
-
|
9 |
-
@mcp.tool(description="A simple greeting")
|
10 |
-
def greet() -> str:
|
11 |
-
headers = get_http_headers()
|
12 |
-
print(f"Received headers: {headers}")
|
13 |
-
name = headers.get("x-given-name", "unknown")
|
14 |
-
return f"Hello, {name}!"
|
15 |
-
|
16 |
-
|
17 |
-
@mcp.tool(description="A simple tool to check token is passed correctly")
|
18 |
-
def safe_header_info() -> dict:
|
19 |
-
"""Safely get header information without raising errors."""
|
20 |
-
# Get headers (returns empty dict if no request context)
|
21 |
-
headers = get_http_headers()
|
22 |
-
|
23 |
-
# Get authorization header
|
24 |
-
auth_header = headers.get("authorization", "")
|
25 |
-
is_bearer = auth_header.startswith("Bearer ")
|
26 |
-
|
27 |
-
return {
|
28 |
-
"user_agent": headers.get("user-agent", "Unknown"),
|
29 |
-
"content_type": headers.get("content-type", "Unknown"),
|
30 |
-
"has_auth": bool(auth_header),
|
31 |
-
"auth_type": "Bearer" if is_bearer else "Other" if auth_header else "None",
|
32 |
-
"headers_count": len(headers),
|
33 |
-
}
|
|
|
5 |
@mcp.tool(description="A simple echo tool")
|
6 |
def echo(message: str) -> str:
|
7 |
return f"Echo: {message}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|