casual-mcp 0.5.0__py3-none-any.whl → 0.7.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,193 @@
1
+ Metadata-Version: 2.4
2
+ Name: casual-mcp
3
+ Version: 0.7.0
4
+ Summary: Multi-server MCP client for LLM tool orchestration
5
+ Author: Alex Stansfield
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/casualgenius/casual-mcp
8
+ Project-URL: Repository, https://github.com/casualgenius/casual-mcp
9
+ Project-URL: Issue Tracker, https://github.com/casualgenius/casual-mcp/issues
10
+ Requires-Python: >=3.10
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: casual-llm[openai]>=0.4.3
14
+ Requires-Dist: dateparser>=1.2.1
15
+ Requires-Dist: fastapi>=0.115.12
16
+ Requires-Dist: fastmcp>=2.12.4
17
+ Requires-Dist: jinja2>=3.1.6
18
+ Requires-Dist: python-dotenv>=1.1.0
19
+ Requires-Dist: questionary>=2.1.0
20
+ Requires-Dist: requests>=2.32.3
21
+ Requires-Dist: rich>=14.0.0
22
+ Requires-Dist: typer>=0.19.2
23
+ Requires-Dist: uvicorn>=0.34.2
24
+ Dynamic: license-file
25
+
26
+ # Casual MCP
27
+
28
+ ![PyPI](https://img.shields.io/pypi/v/casual-mcp)
29
+ ![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)
30
+
31
+ **Casual MCP** is a Python framework for building, evaluating, and serving LLMs with tool-calling capabilities using [Model Context Protocol (MCP)](https://modelcontextprotocol.io).
32
+
33
+ ## Features
34
+
35
+ - Multi-server MCP client using [FastMCP](https://github.com/jlowin/fastmcp)
36
+ - OpenAI and Ollama provider support (via [casual-llm](https://github.com/AlexStansfield/casual-llm))
37
+ - Recursive tool-calling chat loop
38
+ - Toolsets for selective tool filtering per request
39
+ - Usage statistics tracking (tokens, tool calls, LLM calls)
40
+ - System prompt templating with Jinja2
41
+ - CLI and API interfaces
42
+
43
+ ## Installation
44
+
45
+ ```bash
46
+ # Using uv
47
+ uv add casual-mcp
48
+
49
+ # Using pip
50
+ pip install casual-mcp
51
+ ```
52
+
53
+ For development:
54
+
55
+ ```bash
56
+ git clone https://github.com/casualgenius/casual-mcp.git
57
+ cd casual-mcp
58
+ uv sync --group dev
59
+ ```
60
+
61
+ ## Quick Start
62
+
63
+ 1. Create `casual_mcp_config.json`:
64
+
65
+ ```json
66
+ {
67
+ "models": {
68
+ "gpt-4.1": { "provider": "openai", "model": "gpt-4.1" }
69
+ },
70
+ "servers": {
71
+ "time": { "command": "python", "args": ["mcp-servers/time/server.py"] }
72
+ }
73
+ }
74
+ ```
75
+
76
+ 2. Set your API key: `export OPENAI_API_KEY=your-key`
77
+
78
+ 3. Start the server: `casual-mcp serve`
79
+
80
+ 4. Make a request:
81
+
82
+ ```bash
83
+ curl -X POST http://localhost:8000/generate \
84
+ -H "Content-Type: application/json" \
85
+ -d '{"model": "gpt-4.1", "prompt": "What time is it?"}'
86
+ ```
87
+
88
+ ## Configuration
89
+
90
+ Configure models, MCP servers, and toolsets in `casual_mcp_config.json`.
91
+
92
+ ```json
93
+ {
94
+ "models": {
95
+ "gpt-4.1": { "provider": "openai", "model": "gpt-4.1" }
96
+ },
97
+ "servers": {
98
+ "time": { "command": "python", "args": ["server.py"] },
99
+ "weather": { "url": "http://localhost:5050/mcp" }
100
+ },
101
+ "tool_sets": {
102
+ "basic": { "description": "Basic tools", "servers": { "time": true } }
103
+ }
104
+ }
105
+ ```
106
+
107
+ See [Configuration Guide](docs/configuration.md) for full details on models, servers, toolsets, and templates.
108
+
109
+ ## CLI
110
+
111
+ ```bash
112
+ casual-mcp serve # Start API server
113
+ casual-mcp servers # List configured servers
114
+ casual-mcp models # List configured models
115
+ casual-mcp toolsets # Manage toolsets interactively
116
+ casual-mcp tools # List available tools
117
+ ```
118
+
119
+ See [CLI & API Reference](docs/cli-api.md) for all commands and options.
120
+
121
+ ## API
122
+
123
+ | Endpoint | Description |
124
+ |----------|-------------|
125
+ | `POST /chat` | Send message history |
126
+ | `POST /generate` | Send prompt with optional session |
127
+ | `GET /generate/session/{id}` | Get session messages |
128
+ | `GET /toolsets` | List available toolsets |
129
+
130
+ See [CLI & API Reference](docs/cli-api.md#api-endpoints) for request/response formats.
131
+
132
+ ## Programmatic Usage
133
+
134
+ ```python
135
+ from casual_llm import SystemMessage, UserMessage
136
+ from casual_mcp import McpToolChat, ProviderFactory, load_config, load_mcp_client
137
+
138
+ config = load_config("casual_mcp_config.json")
139
+ mcp_client = load_mcp_client(config)
140
+
141
+ provider_factory = ProviderFactory()
142
+ provider = provider_factory.get_provider("gpt-4.1", config.models["gpt-4.1"])
143
+
144
+ chat = McpToolChat(mcp_client, provider)
145
+ messages = [
146
+ SystemMessage(content="You are a helpful assistant."),
147
+ UserMessage(content="What time is it?")
148
+ ]
149
+ response = await chat.chat(messages)
150
+ ```
151
+
152
+ See [Programmatic Usage Guide](docs/programmatic-usage.md) for `McpToolChat`, usage statistics, toolsets, and common patterns.
153
+
154
+ ## Architecture
155
+
156
+ Casual MCP orchestrates LLMs and MCP tool servers in a recursive loop:
157
+
158
+ ```
159
+ ┌─────────────┐ ┌──────────────┐ ┌─────────────┐
160
+ │ MCP Servers │─────▶│ Tool Cache │─────▶│ Tool Converter│
161
+ └─────────────┘ └──────────────┘ └─────────────┘
162
+ │ │
163
+ ▼ ▼
164
+ ┌──────────────────────────────┐
165
+ │ McpToolChat Loop │
166
+ │ │
167
+ │ LLM ──▶ Tool Calls ──▶ MCP │
168
+ │ ▲ │ │
169
+ │ └──────── Results ─────┘ │
170
+ └──────────────────────────────┘
171
+ ```
172
+
173
+ 1. **MCP Client** connects to tool servers (local stdio or remote HTTP/SSE)
174
+ 2. **Tool Cache** fetches and caches tools from all servers
175
+ 3. **ProviderFactory** creates LLM providers from casual-llm
176
+ 4. **McpToolChat** runs the recursive loop until the LLM provides a final answer
177
+
178
+ ## Environment Variables
179
+
180
+ | Variable | Default | Description |
181
+ |----------|---------|-------------|
182
+ | `OPENAI_API_KEY` | - | Required for OpenAI provider |
183
+ | `TOOL_RESULT_FORMAT` | `result` | `result`, `function_result`, or `function_args_result` |
184
+ | `MCP_TOOL_CACHE_TTL` | `30` | Tool cache TTL in seconds (0 = indefinite) |
185
+ | `LOG_LEVEL` | `INFO` | Logging level |
186
+
187
+ ## Troubleshooting
188
+
189
+ Common issues and solutions are covered in the [Troubleshooting Guide](docs/troubleshooting.md).
190
+
191
+ ## License
192
+
193
+ [MIT License](LICENSE)
@@ -0,0 +1,23 @@
1
+ casual_mcp/__init__.py,sha256=eeI1TIj8Cu-H4OMV64LaNqVqo4wSFaGu7215hJeN_HM,598
2
+ casual_mcp/cli.py,sha256=yzNkS2rZ8Lb-1nGFY75RUaixHf1x-vf6gdUPU58jOlg,14953
3
+ casual_mcp/convert_tools.py,sha256=mlH18DTGGeWb0Vxfj1cUSMhTGRE9z8q_xWrVXvpg3mE,1742
4
+ casual_mcp/logging.py,sha256=S2XpLIKHHDtmru_YBFLdMamdmYRm16Yw3tshE3g3Wqg,932
5
+ casual_mcp/main.py,sha256=OxW6itdauq23QyxPhCt6K0kM2jV2WlP_JSfk5IKSN48,6057
6
+ casual_mcp/mcp_tool_chat.py,sha256=h9-1wzgLIhm6kfaNHNJ3RGwkL3A3Q3EoUZvnxIroL74,11144
7
+ casual_mcp/provider_factory.py,sha256=Jp2HQOJdlDDed-hfZf1drEVbw0kpZSE0TN9G0Dcp4w8,1260
8
+ casual_mcp/tool_cache.py,sha256=VE599sF7vHH6megcueqVxCZavvTcoFDoZu2QuZM3cYA,3161
9
+ casual_mcp/tool_filter.py,sha256=u1C8w0CNZ4AH4bbkIRz0ph9-g9-OxSBnkZiLJVapyHo,5430
10
+ casual_mcp/utils.py,sha256=XxzPxQ3j97edeCRXtoO8lJS9R0JYOa25p2MJNwGapJA,3201
11
+ casual_mcp/models/__init__.py,sha256=2D3grALibdsymdpI82EHVGCgEKCszU418qh61os7_rM,924
12
+ casual_mcp/models/chat_stats.py,sha256=ZjeZ_ckx-SfioYs39NAaQxK6qPG9SlFlrB7j7jHZ40w,1221
13
+ casual_mcp/models/config.py,sha256=JsgRtZzA3jZALfAKj-nMIJjnd4RmGmJsLUdzQ_6wCZk,436
14
+ casual_mcp/models/generation_error.py,sha256=abDAahS2fhYkS-ARng1Tk7oudoAO4imkoKYcC9PHT2U,272
15
+ casual_mcp/models/mcp_server_config.py,sha256=0OHsHUEKxRoCl21lsye4E5GoCNmdZWIZCOOthcTpdsE,539
16
+ casual_mcp/models/model_config.py,sha256=59Y7MvcboPKdAilSwUyeC7lfRm4aYkFhZ5c8EVRP5ys,425
17
+ casual_mcp/models/toolset_config.py,sha256=k95TqhHXYDonAt0GG5akzZRWzQ6rZG77eLB7QlSV5AA,1246
18
+ casual_mcp-0.7.0.dist-info/licenses/LICENSE,sha256=U3Zu2tkrh5vXdy7gIdE8WJGM9D4gGp3hohAAWdre-yo,1058
19
+ casual_mcp-0.7.0.dist-info/METADATA,sha256=8S2ssCaPlmVS3zYobzuzRKsLSyyKP_QHzjRCAtfdP80,6211
20
+ casual_mcp-0.7.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
21
+ casual_mcp-0.7.0.dist-info/entry_points.txt,sha256=X48Np2cwl-SlRQdV26y2vPZ-2tJaODgZeVtfpHho-zg,50
22
+ casual_mcp-0.7.0.dist-info/top_level.txt,sha256=K4CiI0Jf8PHICjuQVm32HuNMB44kp8Lb02bbbdiH5bo,11
23
+ casual_mcp-0.7.0.dist-info/RECORD,,