{"id":28825111,"url":"https://github.com/dynstat/agents-mcp-clients","last_synced_at":"2026-04-26T01:32:08.663Z","repository":{"id":290999540,"uuid":"973356464","full_name":"dynstat/agents-mcp-clients","owner":"dynstat","description":"A working example of your own agents from the scratch and using it with the mcp servers from scratch","archived":false,"fork":false,"pushed_at":"2025-05-04T17:22:49.000Z","size":58,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-26T01:32:07.161Z","etag":null,"topics":["agents","mcp","mcp-client","mcp-server"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dynstat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-26T20:09:04.000Z","updated_at":"2025-05-04T17:22:52.000Z","dependencies_parsed_at":"2025-05-01T20:41:36.398Z","dependency_job_id":null,"html_url":"https://github.com/dynstat/agents-mcp-clients","commit_stats":null,"previous_names":["dynstat/agents-mcp-clients"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dynstat/agents-mcp-clients","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynstat%2Fagents-mcp-clients","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynstat%2Fagents-mcp-clients/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynstat%2Fagents-mcp-clients/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynstat%2Fagents-mcp-clients/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dynstat","download_url":"https://codeload.github.com/dynstat/agents-mcp-clients/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dynstat%2Fagents-mcp-clients/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32283294,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T18:29:39.964Z","status":"ssl_error","status_checked_at":"2026-04-25T18:29:32.149Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agents","mcp","mcp-client","mcp-server"],"created_at":"2025-06-19T01:34:30.418Z","updated_at":"2026-04-26T01:32:08.658Z","avatar_url":"https://github.com/dynstat.png","language":"Python","funding_links":[],"categories":["🔧 Utilities","🔧 Utilities \u0026 Helpers"],"sub_categories":[],"readme":"# MCP File Operations Agent\n\nA simple Model Context Protocol (MCP) implementation providing file system operations through a server-client architecture.\n\n## Components\n\n- **file_agent_server.py**: MCP server exposing file system operations as tools\n- **file_agent_client.py**: Client implementation using Google's Gemini API\n\n## Features\n\n- Read file contents\n- Write content to files\n- List directory contents\n\n## Requirements\n\n- Python ≥3.12\n- `mcp[cli]\u003e=1.6.0`\n- `google-genai\u003e=1.12.1`\n- `python-dotenv`\n\n## Setup\n\n1. Install dependencies: `pip install -e .`\n2. Create a `.env` file with your API keys (see `.env-sample`)\n3. Run server: `python file_agent_server.py`\n4. Run client: `python file_agent_client.py`\n5. For SSE example: `python sse_echo.py`\n\n## Implementing MCP Agents\n\nHere's how to set up MCP servers and clients using different transport layers:\n\n### Stdio Transport (Standard Input/Output)\n\nStdio transport is useful for local inter-process communication, often used when a client application spawns a server process.\n\n**Server (`file_agent_server.py` example):**\n\n```python\n# file_agent_server.py\nfrom mcp.server.fastmcp import FastMCP\nimport os # Example tool dependencies\n\n# 1. Create a FastMCP server instance\nfile_agent = FastMCP(\"File Operations Agent\")\n\n# 2. Define tools using the @file_agent.tool() decorator\n@file_agent.tool()\ndef read_file(file_path: str) -\u003e str:\n    \"\"\"Read the contents of a file.\"\"\"\n    try:\n        with open(file_path, 'r', encoding='utf-8') as f:\n            return f.read()\n    except Exception as e:\n        return f\"Error reading file: {str(e)}\"\n\n# Add other tools (write_file, list_directory) similarly...\n\n# 3. Run the server (automatically uses Stdio)\nif __name__ == \"__main__\":\n    file_agent.run()\n```\n\n**Client (`file_agent_client.py` example):**\n\n```python\n# file_agent_client.py\nimport asyncio\nfrom mcp import ClientSession, StdioServerParameters, types as mcp_types\nfrom mcp.client.stdio import stdio_client\n\n# 1. Define server parameters (how to start the server process)\nserver_params = StdioServerParameters(\n    command=\"python\", # Command to execute\n    args=[\"file_agent_server.py\"], # Arguments for the command\n)\n\nasync def run_client():\n    try:\n        # 2. Use stdio_client to start the server process and get read/write streams\n        async with stdio_client(server_params) as (read, write):\n            print(\"stdio_client connected.\")\n            # 3. Create a ClientSession with the streams\n            # Optionally pass a sampling_callback for agent logic\n            async with ClientSession(read, write) as session:\n                print(\"ClientSession created.\")\n                # 4. Initialize the connection\n                await session.initialize()\n                print(\"Session initialized.\")\n\n                # 5. List available tools\n                list_tools_result = await session.list_tools()\n                print(\"Available tools:\", list_tools_result.tools)\n\n                # 6. Call a tool\n                call_result = await session.call_tool(\"read_file\", {\"file_path\": \"README.md\"})\n                if call_result.content and isinstance(call_result.content[0], mcp_types.TextContent):\n                    print(\"Read file result:\", call_result.content[0].text[:100] + \"...\")\n                else:\n                    print(\"Error or unexpected result:\", call_result)\n\n    except Exception as e:\n        print(f\"Client error: {e}\")\n\nif __name__ == \"__main__\":\n    asyncio.run(run_client())\n\n```\n\n### SSE Transport (Server-Sent Events)\n\nSSE transport uses HTTP for communication, suitable for web-based or network-based interactions.\n\n**Server (`sse_echo.py` example):**\n\n```python\n# sse_server_example.py (based on sse_echo.py)\nimport asyncio\nfrom mcp import FastMCP\nfrom mcp.types import TextContent # Example type import\n\n# Define connection details\nHOST = \"127.0.0.1\"\nPORT = 8765\nSSE_PATH = \"/sse\" # The HTTP path for the SSE endpoint\n\n# 1. Instantiate FastMCP with SSE configuration\napp = FastMCP(name=\"SSE Echo Server\", host=HOST, port=PORT, sse_path=SSE_PATH)\n\n# 2. Define tools as usual\n@app.tool()\nasync def echo(text: str) -\u003e list[TextContent]:\n    \"\"\"Echoes the input text back.\"\"\"\n    print(f\"Server received: {text}\")\n    return [TextContent(type=\"text\", text=f\"Echo: {text}\")]\n\n# 3. Run the server asynchronously using run_sse_async\nasync def run_server():\n    print(f\"Starting SSE server on http://{HOST}:{PORT}{SSE_PATH}\")\n    await app.run_sse_async()\n\nif __name__ == \"__main__\":\n    asyncio.run(run_server())\n\n```\n\n**Client (`sse_echo.py` example):**\n\n```python\n# sse_client_example.py (based on sse_echo.py)\nimport asyncio\nfrom mcp import ClientSession\nfrom mcp.client.sse import sse_client # SSE specific client helper\nfrom mcp.types import TextContent, CallToolResult # Example type imports\n\n# Server connection details (must match the server)\nHOST = \"127.0.0.1\"\nPORT = 8765\nSSE_PATH = \"/sse\"\n\nasync def run_client():\n    server_url = f\"http://{HOST}:{PORT}{SSE_PATH}\"\n    print(f\"Client connecting to {server_url}\")\n\n    try:\n        # Allow server time to start (in combined demo scripts)\n        await asyncio.sleep(1)\n\n        # 1. Use sse_client helper to connect to the server URL\n        async with sse_client(url=server_url) as (read, write):\n             print(\"sse_client connected.\")\n             # 2. Create ClientSession with the read/write streams\n             async with ClientSession(read, write) as session:\n                print(\"ClientSession created.\")\n                # 3. Initialize the session\n                await session.initialize()\n                print(\"Session initialized.\")\n\n                # 4. Call a tool\n                message = \"Hello via SSE!\"\n                response: CallToolResult = await session.call_tool(\"echo\", {\"text\": message})\n\n                # Process response\n                if response.content and isinstance(response.content[0], TextContent):\n                     print(f\"Client received: {response.content[0].text}\")\n                else:\n                     print(f\"Client received unexpected response: {response}\")\n\n    except Exception as e:\n        print(f\"Client error: {e}\")\n\nif __name__ == \"__main__\":\n    asyncio.run(run_client())\n```\n\n## Cursor IDE Integration (sample example)\n\nConfigure in `.cursor/mcp.json`:\n```json\n{\n  \"mcpServers\": {\n    \"File Operations Agent\": {\n      \"command\": \"python\",\n      \"args\": [\"path/to/file_agent_server.py\"],\n      \"env\": {}\n    }\n  }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdynstat%2Fagents-mcp-clients","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdynstat%2Fagents-mcp-clients","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdynstat%2Fagents-mcp-clients/lists"}