An AI-powered operations platform for hotshot trucking businesses, featuring intelligent agents for dispatch, rate analysis, compliance tracking, and route optimization.
- Dispatch Agent: Automated load matching from multiple load boards (DAT, Truckstop.com)
- Rate Analysis Agent: Real-time rate per mile calculations and market intelligence
- Compliance Agent: IFTA tracking, HOS monitoring, and DOT compliance automation
- Route Optimizer: Deadhead reduction and fuel-efficient route planning
- Settlement Agent: Automated driver pay calculations and expense tracking
- Load Boards: DAT, Truckstop.com API access
- Mapping: Route planning, distance calculations, traffic analysis
- Financial: Fuel cost tracking, profit margin analysis, expense categorization
- Tracking: Real-time GPS integration and shipment status updates
- Truckstop Server: Custom MCP for Truckstop.com load board
- DAT Server: DAT Load Board and RateView market data
- Fuel Server: Real-time fuel price tracking and optimization
freight-ops/
├── src/
│ ├── agents/ # AI agents for freight operations
│ │ ├── dispatch.py
│ │ ├── rate_analysis.py
│ │ ├── compliance.py
│ │ ├── route_optimizer.py
│ │ └── settlement.py
│ ├── tools/ # MCP tool integrations
│ │ ├── load_boards/
│ │ ├── mapping/
│ │ ├── financials/
│ │ └── tracking/
│ ├── core/ # Shared infrastructure
│ │ ├── sandbox.py
│ │ ├── mcp_registry.py
│ │ └── config.py
│ └── data/
│ └── models/ # Pydantic data models
├── mcp_servers/ # Custom MCP server implementations
│ ├── truckstop/
│ ├── dat/
│ └── fuel/
├── config/ # Configuration files
│ ├── config.yaml
│ └── llms.json
├── notebooks/ # Jupyter notebooks for analysis
├── scripts/ # Utility scripts
└── tests/ # Test suite
- Python 3.12 or higher
- uv package manager
- API keys for load boards and LLM providers
- Clone the repository:
git clone <repository-url>
cd freight-ops- Install dependencies with uv:
uv sync- Configure environment variables:
cp .env.example .env
# Edit .env with your API keys- Update configuration:
# Edit config/config.yaml with your business rules
# Edit config/llms.json with your preferred LLM providersSee .env.example for all required variables:
- Load Board APIs:
DAT_API_KEY,TRUCKSTOP_API_KEY - LLM Providers:
OPENAI_API_KEY,ANTHROPIC_API_KEY - Mapping:
GOOGLE_MAPS_API_KEY - Database:
DATABASE_URL
Configure your business-specific thresholds:
- Minimum acceptable rate per mile
- Maximum deadhead percentage
- Fuel surcharge calculations
- Driver settlement percentages
- Insurance and operating costs
Assign specific models to each agent:
- Dispatch agent: GPT-4 for complex decision-making
- Rate analysis: Claude for numerical analysis
- Compliance: Smaller models for structured tasks
# Dispatch agent - find and book loads
python -m src.agents.dispatch
# Rate analysis - analyze market rates
python -m src.agents.rate_analysis --lane "TX-CA"
# Compliance check - generate IFTA report
python -m src.agents.compliance --report ifta --quarter Q1# Start Jupyter for data analysis
jupyter notebook notebooks/
# Common notebooks:
# - rate_trends.ipynb: Analyze historical rate data
# - route_analysis.ipynb: Optimize common lanes
# - profit_analysis.ipynb: Margin analysis by load type# All tests
pytest tests/
# Specific test suite
pytest tests/agents/test_dispatch.py
# With coverage
pytest --cov=src tests/The fundamental metric for load profitability:
RPM = Total Revenue / Loaded Miles
Consider:
- Base rate from shipper/broker
- Fuel surcharge
- Accessorial charges (detention, layover, etc.)
- Deadhead miles impact on overall profitability
Minimize empty miles:
Deadhead % = (Deadhead Miles / Total Miles) * 100
Target: Keep below 10-15% for optimal profitability
Track fuel purchases and miles by jurisdiction:
- Record every fuel purchase (gallons, price, location)
- Track miles driven in each state/province
- Generate quarterly reports
- Calculate tax owed or refund due
Calculate driver pay accurately:
Gross Pay = Revenue * Driver Percentage
Net Pay = Gross Pay - Advances - Fuel - Deductions + Reimbursements
- Create agent file in
src/agents/ - Inherit from
BaseAgent - Define required tools via MCP
- Implement decision logic with clear reasoning
- Add tests in
tests/agents/ - Update
config/llms.jsonwith model assignment
- Create directory in
mcp_servers/ - Implement MCP protocol handlers
- Define tool schemas
- Add authentication handling
- Document API endpoints used
- Add integration tests
MCP Inspector is an
interactive UI for stepping through an MCP server's tools, resources, and
prompts over stdio. The scripts/mcp_inspector.sh wrapper launches it
against this project's servers:
# Inspect one of the built-in servers
scripts/mcp_inspector.sh truckstop
scripts/mcp_inspector.sh dat
scripts/mcp_inspector.sh fuel
# Inspect any other stdio MCP server
scripts/mcp_inspector.sh -- uv run python -m mcp_servers.customRequires Node.js (for npx) and the project's uv environment. The
inspector is fetched on demand via npx --yes, so no global install is
needed.
Use Pydantic for all data structures:
from pydantic import BaseModel, Field
class Load(BaseModel):
load_id: str
origin: Location
destination: Location
pickup_date: datetime
delivery_date: datetime
rate: Decimal = Field(gt=0)
miles: int = Field(gt=0)
weight: int
commodity: strThis platform is designed to integrate with open-ptc-agent:
- All tools exposed via MCP protocol
- Agents can be orchestrated by open-ptc-agent
- Shared context through structured data models
- Compatible with Claude Desktop and other MCP clients
- Real-time load monitoring and alerts
- Predictive rate modeling with historical data
- Multi-agent collaboration for complex scenarios
- Mobile app for driver communication
- Integration with TMS (Transportation Management Systems)
- Blockchain for transparent load tracking
- Insurance claim automation
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
[Your chosen license]
For issues and questions:
- GitHub Issues: [repository-url]/issues
- Documentation: [docs-url]
- Built with the MCP (Model Context Protocol)
- Integrates with open-ptc-agent
- Powered by Claude and GPT models