Skip to main content

FlyMoon Python Package for MCP (Mission Control Protocol) clients and server

Project description

FlyMoon - MCP Server and Client

A Python package for both the MCP (Mission Control Protocol) Server and Client. This library provides a server implementation for agent simulations and a simple client wrapper around the MCP Server API to register agents, move them around, and observe the environment.

Table of Contents

Installation

Option 1: Install from PyPI (Recommended)

pip install flymoon

Option 2: Install from Source

  1. Clone this repository:
git clone https://github.com/Tanishqpy/FlyMoon
cd FlyMoon
pip install -e .
  1. Install the required dependencies:
pip install -r requirements.txt
  1. (Optional) Create a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

Usage

Client Usage

from flymoon import MCPClient

# Create a client instance
client = MCPClient(
    server_url="http://localhost:8000",
    agent_id="explorer_bot",
    agent_type="scout"
)

# Register the agent
registration_result = client.register()
print(f"Registration result: {registration_result}")

# Move the agent
move_result = client.move(x=10, y=5)
print(f"Move result: {move_result}")

# Observe surroundings
observation = client.observe()
print(f"Observation: {observation}")

Server Usage

from flymoon.server import start_server

# Start the server on default host and port (0.0.0.0:8000)
start_server()

# Or specify custom host and port
start_server(host="127.0.0.1", port=9000)

The server can also be started directly from the command line:

# Using the module
python -m flymoon.server

# Or if installed as a package
python -c "from flymoon.server import start_server; start_server()"

Automated Agent Loop

The client also includes a simple automation function:

# Run a simple agent loop (5 steps by default)
client = MCPClient(agent_id="explorer_bot", agent_type="scout")
client.run_simple_loop(steps=5, delay=1)

API Reference

Client API

MCPClient

Constructor
  • MCPClient(server_url="http://localhost:8000", agent_id=None, agent_type=None)
Methods
  • register(agent_id=None, agent_type=None): Register an agent with the server
  • move(x, y): Move the agent to the specified coordinates
  • observe(): Observe the surroundings
  • run_simple_loop(steps=5, delay=1): Run an automated agent loop

Server API

Endpoints

  • GET /: Check if the server is running
  • POST /step: Main endpoint for agent actions

Step Request Types

  1. Register

    {
      "type": "register",
      "agent_id": "unique_agent_id",
      "agent_type": "scout"
    }
    
  2. Move

    {
      "type": "move",
      "agent_id": "unique_agent_id",
      "target": {"x": 10, "y": 20}
    }
    
  3. Observe

    {
      "type": "observe",
      "agent_id": "unique_agent_id"
    }
    

Server Functions

  • start_server(host="0.0.0.0", port=8000): Start the MCP server

Project Structure

  • src/FlyMoon/
    • __init__.py: Package initialization
    • mcp_client.py: Main client library class
    • server.py: FastAPI server implementation
    • agent_client.py: Example implementation without using the wrapper
    • mcp_env.py: Environment definition and functionality
  • launch_mcp.sh: Script to start the server with ngrok tunneling
  • requirements.txt: Project dependencies
  • pyproject.toml: Project configuration

Example Agent

See agent_client.py for a simple example of directly using the API without the wrapper.

Troubleshooting

Common Issues

  1. Connection refused errors

    • Make sure the MCP server is running on the specified port
    • Check if the server URL is correct
    • Verify network connectivity
  2. Authentication failures

    • Ensure you're using a valid agent_id
    • Try re-registering your agent
  3. Movement limitations

    • Agents can't move outside the environment boundaries
    • Check observation results for valid movement ranges

Server Setup

To start the server locally:

# Start the FastAPI server
uvicorn flymoon.server:app --reload

# Or use the provided launch script
./launch_mcp.sh

Contributing

Contributions are welcome! Here's how you can contribute:

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Commit your changes (git commit -m 'Add some amazing feature')
  5. Push to the branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

Please make sure to update tests as appropriate.

License

MIT License

Copyright (c) 2025 Tanishq

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flymoon-0.1.2.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flymoon-0.1.2-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file flymoon-0.1.2.tar.gz.

File metadata

  • Download URL: flymoon-0.1.2.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for flymoon-0.1.2.tar.gz
Algorithm Hash digest
SHA256 300ca8e124a0b9ddbd64337283e7ba38d6d3f39c7053ddf1d8bd3918d32edf3f
MD5 1c1129a5753f1de44455c22fda0b6990
BLAKE2b-256 90084b5f05f9019fad80e6f67213f9e6ea30323b4fc51710fb621841e283ff9a

See more details on using hashes here.

File details

Details for the file flymoon-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: flymoon-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for flymoon-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2d2c577e2dc356b0e62064c0b9b22d99e99c32c651a919615f204b05fdcf60ec
MD5 0b3b441f02b8924dd15c748f9be4255f
BLAKE2b-256 803902a79e2e8f2ad26a467d9f66196d4ff35f43fedd7347bca7959345289088

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page