{"id":9535,"library":"awslabs-core-mcp-server","title":"AWS Labs Core Model Context Protocol Server","description":"The `awslabs-core-mcp-server` library provides a Python implementation of an AWS Labs Model Context Protocol (MCP) server. It allows for the creation of in-memory MCP servers, facilitating communication and context management for models over WebSockets. The current version is 1.0.27, and releases appear to be driven by the needs of the broader MCP project rather than a fixed schedule.","status":"active","version":"1.0.27","language":"en","source_language":"en","source_url":"https://github.com/awslabs/mcp","tags":["aws","server","protocol","websockets","asyncio","mcp"],"install":[{"cmd":"pip install awslabs-core-mcp-server","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for the underlying WebSocket server implementation.","package":"websockets","optional":false}],"imports":[{"symbol":"InMemoryModelContextProtocolServer","correct":"from awslabs_core_mcp_server.model_context_protocol import InMemoryModelContextProtocolServer"}],"quickstart":{"code":"import asyncio\nimport websockets\nfrom awslabs_core_mcp_server.model_context_protocol import InMemoryModelContextProtocolServer\n\nasync def run_server():\n    # Example initial data (can be empty or loaded from a file)\n    initial_data = {\n        \"context_id_1\": {\"model_id\": \"model_A\", \"context\": {\"key\": \"value\"}}\n    }\n    \n    # Initialize the in-memory MCP server with optional initial data\n    server_instance = InMemoryModelContextProtocolServer(initial_data=initial_data)\n    \n    # Start the WebSocket server\n    port = 8080\n    host = \"localhost\"\n    print(f\"Starting MCP server on ws://{host}:{port}\")\n    async with websockets.serve(server_instance.handle_request, host, port):\n        await asyncio.Future() # Run forever\n\nif __name__ == \"__main__\":\n    try:\n        asyncio.run(run_server())\n    except KeyboardInterrupt:\n        print(\"\\nServer stopped gracefully.\")","lang":"python","description":"This quickstart demonstrates how to instantiate and run an in-memory Model Context Protocol (MCP) server using `asyncio` and `websockets`. The server will listen for WebSocket connections and handle MCP requests. The `initial_data` argument is optional and can be used to pre-populate the server's context."},"warnings":[{"fix":"Ensure a proper `asyncio` event loop is running and managed. Use `asyncio.run()` for simple scripts, and handle `KeyboardInterrupt` for graceful shutdown. For complex applications, integrate the server within an existing event loop.","message":"The server heavily relies on Python's `asyncio` library. Users unfamiliar with asynchronous programming in Python might face challenges with correctly integrating, starting, and gracefully shutting down the server within their applications.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always specify a port that is known to be free for your environment. In programmatic setup, change the `port` variable. If using the CLI, provide `--port <new_port>`.","message":"By default, the quickstart and CLI examples often use a common port (e.g., 8080). This can lead to port contention if another application is already using that port, preventing the MCP server from starting.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Stop the process using the port, or configure the MCP server to listen on a different, available port (e.g., 8081, 9000). For the quickstart, modify `port = 8080` to another value.","cause":"The network port specified for the MCP server is already being used by another process or application.","error":"OSError: [Errno 98] Address already in use"},{"fix":"Install the package using pip: `pip install awslabs-core-mcp-server`.","cause":"The `awslabs-core-mcp-server` package has not been installed in the active Python environment.","error":"ModuleNotFoundError: No module named 'awslabs_core_mcp_server'"},{"fix":"Verify client-side WebSocket implementation for proper connection management and graceful closures. Check network stability and firewall configurations. For server-side, it often indicates a client-side issue rather than a server bug.","cause":"This error typically occurs when a client disconnects unexpectedly or without sending a proper WebSocket close frame, or if there's a network interruption.","error":"websockets.exceptions.ConnectionClosedOK: no close frame received"}]}