QUICKSTART.md•3 kB
# Quick Start Guide
## Installation (5 minutes)
### 1. Install Dependencies
```bash
pip install mcp aiofiles pyyaml
```
### 2. Test the Server
```bash
# Test basic functionality
python examples/test_client.py
```
You should see output showing:
- 18 registered tools
- Calculator operations working
- File operations working
- Error handling working
## Usage with LangGraph
### Basic Example
```python
import asyncio
import sys
from pathlib import Path
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
async def main():
# Start MCP server
server_params = StdioServerParameters(
command=sys.executable,
args=[str(Path("src/server.py"))],
)
# Connect and use tools
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
# Call calculator tool
result = await session.call_tool(
"calculator_add",
{"a": 10, "b": 5}
)
print(result.content[0].text)
# Output: {"result": 15.0, "operation": "add", ...}
# Call file tool
result = await session.call_tool(
"file_write",
{"file_path": "test.txt", "content": "Hello!"}
)
print(result.content[0].text)
# Output: {"success": true, "bytes_written": 6, ...}
asyncio.run(main())
```
## Available Tools
### Calculator (10 tools)
- `calculator_add`, `calculator_subtract`, `calculator_multiply`, `calculator_divide`
- `calculator_power`, `calculator_sqrt`, `calculator_log`
- `calculator_sin`, `calculator_cos`, `calculator_tan`
### File Operations (8 tools)
- `file_read`, `file_read_lines`, `file_exists`, `file_list`
- `file_write`, `file_append`, `file_create`, `file_delete`
## Key Features
**Security:**
- All file operations sandboxed to `workspace/` directory
- Only relative paths accepted
- File size limits (10MB default)
- Extension filtering
**Configuration:**
- Edit `config/config.yaml` or use environment variables
- `MCP_DEBUG=true` for verbose logging
- `MCP_LOG_LEVEL=DEBUG` for detailed logs
**Logging:**
- Logs written to `logs/mcp_server.log`
- Console output to stderr (stdout reserved for MCP protocol)
## Next Steps
1. Run `python examples/langgraph_integration.py` for more examples
2. Read `README.md` for full documentation
3. Add your own tools in `src/tools/` following the pattern
4. Configure `config/config.yaml` for your needs
## Troubleshooting
**Server won't start?**
- Check Python 3.10+
- Install dependencies: `pip install mcp aiofiles pyyaml`
**File operation fails?**
- Use relative paths: `data/file.txt` not `/abs/path`
- Check workspace exists: `workspace/` directory
- Verify in sandbox: paths must be under `workspace/`
**Tool not found?**
- Restart server after adding new tools
- Check tool imported in `src/tools/__init__.py`