Skip to main content
Glama
harishsg993010

Damn Vulnerable Model Context Protocol (DVMCP)

sse_server.cpython-310.pyc2.33 kB
o J-�gJ�@sVddlmZmZddlmZddlmZddlmZm Z ddl m Z Gdd�d�Z dS) �)�FastMCP�Context)�SseServerTransport)� Starlette)�Mount�Route)�FastAPIc@s,eZdZdd�Zdd�Zdd�Zdd�Zd S) �SseCompatibleMcpServercCst|�|_||_t�|_dS)N)r�mcp�portr�app)�self�namer �r�5/home/ubuntu/damn-vulnerable-mcs/common/sse_server.py�__init__ s  zSseCompatibleMcpServer.__init__cCs|j�d|���dS)z'Mount the SSE server to the FastAPI app�/N)r �mount�create_sse_server)r rrr�mount_sse_serversz'SseCompatibleMcpServer.mount_sse_servercs:td����fdd�}td|d�td�jd�g}t|d�S) zHCreate a Starlette app that handles SSE connections and message handlingz /messages/c �sx���|j|j|j�4IdH� }�jj�|d|d�jj���IdHWd�IdHdS1IdHs5wYdS)Nr�)� connect_sse�scope�receive�_sendr � _mcp_server�run�create_initialization_options)�request�streams�r � transportrr� handle_sses�  � �.�z<SseCompatibleMcpServer.create_sse_server.<locals>.handle_sse�/sse)�endpointz /messages)r )�routes)rrr�handle_post_messager)r r"r%rr rrs  � z(SseCompatibleMcpServer.create_sse_servercCs^ddl}td|jj�d��td�td|j���td|j�d��|j|jd |jd �dS) zRun the server with uvicornrNz Starting z MCP ServerzKConnect to this server using an MCP client (e.g., Claude Desktop or Cursor)z#Server running at http://localhost:z+SSE endpoint available at http://localhost:r#z0.0.0.0)�hostr )�uvicorn�printr rr rr )r r(rrrr(s zSseCompatibleMcpServer.runN)�__name__� __module__� __qualname__rrrrrrrrr s  r N) �mcp.server.fastmcprr�mcp.server.sser�starlette.applicationsr�starlette.routingrr�fastapirr rrrr�<module>s    

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/harishsg993010/damn-vulnerable-MCP-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server