iflow-mcp_modelcontextinterface-mcix 1.1.1.dev0__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.
- iflow_mcp_modelcontextinterface_mcix-1.1.1.dev0.dist-info/METADATA +931 -0
- iflow_mcp_modelcontextinterface_mcix-1.1.1.dev0.dist-info/RECORD +42 -0
- iflow_mcp_modelcontextinterface_mcix-1.1.1.dev0.dist-info/WHEEL +4 -0
- iflow_mcp_modelcontextinterface_mcix-1.1.1.dev0.dist-info/entry_points.txt +2 -0
- iflow_mcp_modelcontextinterface_mcix-1.1.1.dev0.dist-info/licenses/LICENSE +21 -0
- mci/__init__.py +10 -0
- mci/assets/example_toolset.mci.json +37 -0
- mci/assets/example_toolset.mci.yaml +23 -0
- mci/assets/gitignore +1 -0
- mci/assets/mci.json +29 -0
- mci/assets/mci.yaml +19 -0
- mci/cli/__init__.py +8 -0
- mci/cli/add.py +108 -0
- mci/cli/envs.py +257 -0
- mci/cli/formatters/__init__.py +12 -0
- mci/cli/formatters/env_formatter.py +83 -0
- mci/cli/formatters/json_formatter.py +93 -0
- mci/cli/formatters/table_formatter.py +138 -0
- mci/cli/formatters/yaml_formatter.py +93 -0
- mci/cli/install.py +147 -0
- mci/cli/list.py +153 -0
- mci/cli/run.py +125 -0
- mci/cli/validate.py +113 -0
- mci/core/__init__.py +8 -0
- mci/core/config.py +144 -0
- mci/core/dynamic_server.py +187 -0
- mci/core/file_finder.py +105 -0
- mci/core/mci_client.py +196 -0
- mci/core/mcp_server.py +240 -0
- mci/core/schema_editor.py +284 -0
- mci/core/tool_converter.py +119 -0
- mci/core/tool_manager.py +118 -0
- mci/core/validator.py +162 -0
- mci/mci.py +39 -0
- mci/py.typed +0 -0
- mci/utils/__init__.py +8 -0
- mci/utils/dotenv.py +170 -0
- mci/utils/env_scanner.py +84 -0
- mci/utils/error_formatter.py +165 -0
- mci/utils/error_handler.py +174 -0
- mci/utils/timestamp.py +50 -0
- mci/utils/validation.py +92 -0
|
@@ -0,0 +1,931 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: iflow-mcp_modelcontextinterface-mcix
|
|
3
|
+
Version: 1.1.1.dev0
|
|
4
|
+
Summary: CLI tool designed to manage MCI (Model Context Interface) schemas and dynamically run MCP servers using defined MCI toolsets
|
|
5
|
+
Project-URL: Repository, https://github.com/Model-Context-Interface/mci
|
|
6
|
+
Project-URL: Homepage, https://github.com/Model-Context-Interface
|
|
7
|
+
Project-URL: Documentation, https://usemci.dev/
|
|
8
|
+
Author-email: maestroerror <revaz@usemci.dev>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Python: <4.0,>=3.11
|
|
21
|
+
Requires-Dist: click>=8.3.0
|
|
22
|
+
Requires-Dist: mci-py>=1.2
|
|
23
|
+
Requires-Dist: mcp>=1.19.0
|
|
24
|
+
Requires-Dist: pytest-cov>=7.0.0
|
|
25
|
+
Requires-Dist: python-dotenv>=1.2.1
|
|
26
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
27
|
+
Requires-Dist: rich>=14.2.0
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# MCI CLI Tool
|
|
31
|
+
|
|
32
|
+
A command-line interface for managing Model Context Interface (MCI) schemas and dynamically running MCP (Model Context Protocol) servers using defined MCI toolsets.
|
|
33
|
+
|
|
34
|
+
## Features
|
|
35
|
+
- Connect existing **MCP servers** with automatic **caching** and easy **filtering** options to make your unique set of tools
|
|
36
|
+
- Define your custom tools in JSON or YAML using clear, reviewable MCI schema
|
|
37
|
+
- API:
|
|
38
|
+
- Connect your n8n, Make and other workflow builders as tools
|
|
39
|
+
- Convert any REST API Docs to AI tools in minute with LLM
|
|
40
|
+
- Run remote code with AWS Lambda, judge0, etc.
|
|
41
|
+
- Authentication, headers, body... Full set of API features are supported
|
|
42
|
+
- CLI:
|
|
43
|
+
- Run server based CLI commands as tool from simple "ls" to anything else you can install with apt-get!
|
|
44
|
+
- Write separated python script and convert in tool in 30 seconds!
|
|
45
|
+
- Build super fast GoLang binary and run as AI tool
|
|
46
|
+
- File:
|
|
47
|
+
- Manage your prompts, generate reports, and provide context with ease
|
|
48
|
+
- Any file becomes a template: From printing simple variables (`{{ props.message }}`) to blocks like if, for & foreach
|
|
49
|
+
- Everything you need to create real, dynamic and usable templates
|
|
50
|
+
- Text:
|
|
51
|
+
- Simplest way to return dynamic or static text from tool
|
|
52
|
+
- Supports full templating as File type, but defined inside .mci.json
|
|
53
|
+
- Ideal for serving dynamic assets (image URLs per user, PDFs, etc)
|
|
54
|
+
- As well as for generating simple messages
|
|
55
|
+
- Make **toolset** from your custom tools: easiest way to organize, manage and share your tools!
|
|
56
|
+
- Everything mentioned above you can use programmatically via [MCI-Adapter](https://github.com/Model-Context-Interface/mci-py) for your language
|
|
57
|
+
- Or.. Instantly serve them as a unified **STDIO MCP server** via `uvx mcix run` command.
|
|
58
|
+
- And... Create separate .mci.json files to serve them as different MCP servers for different agents! Reducing token and runtime overhead by providing small, specific context files tailored per agent.
|
|
59
|
+
|
|
60
|
+
Everything simple, super flexible and still, high performant!
|
|
61
|
+
|
|
62
|
+
> Check out the [documentation](https://usemci.dev/) for general understanding of MCI (We are working hard to update docs with `uvx mcix` tool usage)
|
|
63
|
+
|
|
64
|
+
## Quick Start
|
|
65
|
+
|
|
66
|
+
No installation needed! Run MCI directly using `uvx`:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Install uv if you haven't already
|
|
70
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Your First MCI Project
|
|
74
|
+
|
|
75
|
+
1. **Initialize a new project**:
|
|
76
|
+
```bash
|
|
77
|
+
uvx mcix install
|
|
78
|
+
```
|
|
79
|
+
This creates `mci.json` with example tools and `mci/` directory with example toolsets.
|
|
80
|
+
|
|
81
|
+
2. **List your tools**:
|
|
82
|
+
```bash
|
|
83
|
+
uvx mcix list
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
3. **Check required environment variables**:
|
|
87
|
+
```bash
|
|
88
|
+
uvx mcix envs
|
|
89
|
+
|
|
90
|
+
# Generate .env template
|
|
91
|
+
uvx mcix envs --format=env
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
4. **Validate your configuration**:
|
|
95
|
+
```bash
|
|
96
|
+
uvx mcix validate
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
5. **Run an MCP server**:
|
|
100
|
+
```bash
|
|
101
|
+
uvx mcix run
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
That's it! Your MCI tools are now available via the MCP protocol.
|
|
105
|
+
|
|
106
|
+
### Optional: Install MCI Globally
|
|
107
|
+
|
|
108
|
+
If you prefer to install MCI permanently:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Install globally with uv
|
|
112
|
+
uv tool install mcix
|
|
113
|
+
|
|
114
|
+
# Then use without uvx prefix
|
|
115
|
+
mcix install
|
|
116
|
+
mcix list
|
|
117
|
+
mcix run
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Or install from source:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
git clone https://github.com/Model-Context-Interface/mci-uvx.git
|
|
124
|
+
cd mci-uvx
|
|
125
|
+
uv sync --all-extras
|
|
126
|
+
uv tool install --editable .
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Core Concepts
|
|
130
|
+
|
|
131
|
+
### MCI Tools
|
|
132
|
+
|
|
133
|
+
MCI tools are reusable, declarative tool definitions that can execute different types of operations:
|
|
134
|
+
|
|
135
|
+
- **Text tools**: Return templated text responses
|
|
136
|
+
- **File tools**: Read and return file contents
|
|
137
|
+
- **CLI tools**: Execute command-line programs
|
|
138
|
+
- **HTTP tools**: Make API requests
|
|
139
|
+
- **MCP tools**: Invoke other MCP servers
|
|
140
|
+
|
|
141
|
+
### Toolsets
|
|
142
|
+
|
|
143
|
+
Toolsets are collections of related tools stored in the `mci/` directory. They can be:
|
|
144
|
+
|
|
145
|
+
- Shared across projects
|
|
146
|
+
- Filtered by tags or names
|
|
147
|
+
- Referenced from your main configuration
|
|
148
|
+
|
|
149
|
+
### MCP Server Integration
|
|
150
|
+
|
|
151
|
+
The `mcix run` command creates an MCP server that:
|
|
152
|
+
|
|
153
|
+
- Dynamically loads tools from your MCI schema
|
|
154
|
+
- Serves them via the Model Context Protocol
|
|
155
|
+
- Can be used with MCP-compatible clients (like Claude Desktop)
|
|
156
|
+
- Supports filtering to expose only specific tools
|
|
157
|
+
|
|
158
|
+
## Available Commands
|
|
159
|
+
|
|
160
|
+
### `mcix install`
|
|
161
|
+
|
|
162
|
+
Bootstrap a new MCI project with starter configuration.
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
# Create JSON configuration (default)
|
|
166
|
+
uvx mcix install
|
|
167
|
+
|
|
168
|
+
# Create YAML configuration
|
|
169
|
+
uvx mcix install --yaml
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Creates:
|
|
173
|
+
- `mci.json` (or `mci.yaml`) - Main configuration file
|
|
174
|
+
- `mci/` directory - Library of toolsets
|
|
175
|
+
- `mci/.gitignore` - Excludes generated files
|
|
176
|
+
|
|
177
|
+
### `mcix list`
|
|
178
|
+
|
|
179
|
+
Display all available tools from your configuration.
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
# List all tools (table format)
|
|
183
|
+
uvx mcix list
|
|
184
|
+
|
|
185
|
+
# List with verbose details
|
|
186
|
+
uvx mcix list --verbose
|
|
187
|
+
|
|
188
|
+
# Filter by tags
|
|
189
|
+
uvx mcix list --filter tags:api,database
|
|
190
|
+
|
|
191
|
+
# Export to JSON
|
|
192
|
+
uvx mcix list --format json
|
|
193
|
+
|
|
194
|
+
# Export to YAML
|
|
195
|
+
uvx mcix list --format yaml
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**Filter types**:
|
|
199
|
+
- `tags:tag1,tag2` - Include tools with any of these tags
|
|
200
|
+
- `only:tool1,tool2` - Include only specific tools
|
|
201
|
+
- `except:tool1,tool2` - Exclude specific tools
|
|
202
|
+
- `toolsets:ts1,ts2` - Include tools from specific toolsets
|
|
203
|
+
- `without-tags:tag1,tag2` - Exclude tools with these tags
|
|
204
|
+
|
|
205
|
+
### `mci envs`
|
|
206
|
+
|
|
207
|
+
List all environment variables referenced in your MCI configuration.
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
# Show environment variables in table format
|
|
211
|
+
uvx mcix envs
|
|
212
|
+
|
|
213
|
+
# Generate .env.example.mci file
|
|
214
|
+
uvx mcix envs --format=env
|
|
215
|
+
|
|
216
|
+
# Check specific schema file
|
|
217
|
+
uvx mcix envs --file=custom.mci.json
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
The `envs` command scans your entire MCI schema including:
|
|
221
|
+
- Main schema file tools and configuration
|
|
222
|
+
- All referenced toolsets
|
|
223
|
+
- MCP server configurations
|
|
224
|
+
|
|
225
|
+
**Output formats**:
|
|
226
|
+
- `table` (default) - Display variables in a formatted table with locations
|
|
227
|
+
- `env` - Generate `.env.example.mci` file with all variables
|
|
228
|
+
|
|
229
|
+
**Example table output**:
|
|
230
|
+
```
|
|
231
|
+
┌─────────────────┬──────────────────┐
|
|
232
|
+
│ Variable │ Used In │
|
|
233
|
+
├─────────────────┼──────────────────┤
|
|
234
|
+
│ API_KEY │ main, weather │
|
|
235
|
+
│ DB_URL │ database │
|
|
236
|
+
│ GITHUB_TOKEN │ mcp:github │
|
|
237
|
+
└─────────────────┴──────────────────┘
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
**Example .env file output**:
|
|
241
|
+
```bash
|
|
242
|
+
# .env.example.mci
|
|
243
|
+
# Environment variables used in MCI configuration
|
|
244
|
+
#
|
|
245
|
+
# Copy this file to .env.mci and fill in your values
|
|
246
|
+
|
|
247
|
+
# Used in: main, weather
|
|
248
|
+
API_KEY=
|
|
249
|
+
|
|
250
|
+
# Used in: database
|
|
251
|
+
DB_URL=
|
|
252
|
+
|
|
253
|
+
# Used in: mcp:github
|
|
254
|
+
GITHUB_TOKEN=
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
> **Tip**: Run `uvx mcix envs --format=env` to generate a template `.env.example.mci` file, then copy it to `.env.mci` and fill in your values. Commit `.env.example.mci` to your repository so team members know what environment variables are needed.
|
|
258
|
+
|
|
259
|
+
### `mcix validate`
|
|
260
|
+
|
|
261
|
+
Validate your MCI schema for correctness.
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
# Validate default configuration
|
|
265
|
+
uvx mcix validate
|
|
266
|
+
|
|
267
|
+
# Validate specific file
|
|
268
|
+
uvx mcix validate --file custom.mci.json
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Checks for:
|
|
272
|
+
- Schema structure and syntax
|
|
273
|
+
- Required fields
|
|
274
|
+
- Data types
|
|
275
|
+
- Tool definitions
|
|
276
|
+
- Toolset references
|
|
277
|
+
- MCP command availability (warnings)
|
|
278
|
+
|
|
279
|
+
### `mcix add`
|
|
280
|
+
|
|
281
|
+
Add toolset references to your schema.
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
# Add a toolset
|
|
285
|
+
uvx mcix add weather-tools
|
|
286
|
+
|
|
287
|
+
# Add with filter
|
|
288
|
+
uvx mcix add analytics --filter=only:Tool1,Tool2
|
|
289
|
+
|
|
290
|
+
# Add with tag filter
|
|
291
|
+
uvx mcix add api-tools --filter=tags:api,database
|
|
292
|
+
|
|
293
|
+
# Add to custom file
|
|
294
|
+
uvx mcix add weather-tools --path=custom.mci.json
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
Automatically preserves your file format (JSON stays JSON, YAML stays YAML).
|
|
298
|
+
|
|
299
|
+
### `mcix run`
|
|
300
|
+
|
|
301
|
+
Launch an MCP server that dynamically serves your tools.
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
# Run with default configuration
|
|
305
|
+
uvx mcix run
|
|
306
|
+
|
|
307
|
+
# Run with specific file
|
|
308
|
+
uvx mcix run --file custom.mci.json
|
|
309
|
+
|
|
310
|
+
# Run with filtered tools
|
|
311
|
+
uvx mcix run --filter tags:production
|
|
312
|
+
|
|
313
|
+
# Run excluding tools
|
|
314
|
+
uvx mcix run --filter except:deprecated_tool
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
The server:
|
|
318
|
+
- Loads tools from your MCI schema
|
|
319
|
+
- Converts them to MCP format
|
|
320
|
+
- Listens on STDIO for MCP requests
|
|
321
|
+
- Delegates execution back to MCIClient
|
|
322
|
+
|
|
323
|
+
**Stop the server**: Press `Ctrl+C`
|
|
324
|
+
|
|
325
|
+
## Example Workflows
|
|
326
|
+
|
|
327
|
+
### Development Workflow
|
|
328
|
+
|
|
329
|
+
```bash
|
|
330
|
+
# 1. Create a new project
|
|
331
|
+
uvx mcix install
|
|
332
|
+
|
|
333
|
+
# 2. Add toolsets
|
|
334
|
+
uvx mcix add weather-tools
|
|
335
|
+
uvx mcix add api-tools --filter=tags:production
|
|
336
|
+
|
|
337
|
+
# 3. Preview your tools
|
|
338
|
+
uvx mcix list --verbose
|
|
339
|
+
|
|
340
|
+
# 4. Check environment variables and generate .env template
|
|
341
|
+
uvx mcix envs --format=env
|
|
342
|
+
|
|
343
|
+
# 5. Validate everything
|
|
344
|
+
uvx mcix validate
|
|
345
|
+
|
|
346
|
+
# 6. Test with MCP server
|
|
347
|
+
uvx mcix run --filter tags:development
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### Production Deployment
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
# Check required environment variables
|
|
354
|
+
uvx mcix envs
|
|
355
|
+
|
|
356
|
+
# Validate before deployment
|
|
357
|
+
uvx mcix validate
|
|
358
|
+
|
|
359
|
+
# Run server with only production tools
|
|
360
|
+
uvx mcix run --filter tags:production
|
|
361
|
+
|
|
362
|
+
# Or exclude experimental features
|
|
363
|
+
uvx mcix run --filter without-tags:experimental,beta
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
### Tool Development
|
|
367
|
+
|
|
368
|
+
```bash
|
|
369
|
+
# Create your schema
|
|
370
|
+
uvx mcix install
|
|
371
|
+
|
|
372
|
+
# Edit mci.json to add your tool
|
|
373
|
+
# (see examples in the generated file)
|
|
374
|
+
|
|
375
|
+
# Validate your changes
|
|
376
|
+
uvx mcix validate
|
|
377
|
+
|
|
378
|
+
# Test your tool
|
|
379
|
+
uvx mcix list --verbose
|
|
380
|
+
uvx mcix run
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
## Supported Execution Types
|
|
384
|
+
|
|
385
|
+
MCI tools support multiple execution types. Below are examples for each type:
|
|
386
|
+
|
|
387
|
+
## Tool Annotations
|
|
388
|
+
|
|
389
|
+
MCI tools support optional annotations that provide metadata and behavioral hints about the tool. These annotations are preserved when serving tools via MCP servers and help MCP clients make better decisions about tool usage and display.
|
|
390
|
+
|
|
391
|
+
### Supported Annotation Fields
|
|
392
|
+
|
|
393
|
+
All annotation fields are optional:
|
|
394
|
+
|
|
395
|
+
- **`title`**: Human-readable title for the tool (alternative to the machine name)
|
|
396
|
+
- **`readOnlyHint`**: `true` if the tool only reads data without modification, `false` if it modifies state
|
|
397
|
+
- **`destructiveHint`**: `true` if the tool may perform destructive updates (delete, overwrite), `false` if only additive
|
|
398
|
+
- **`idempotentHint`**: `true` if calling the tool repeatedly with the same arguments has no additional effect
|
|
399
|
+
- **`openWorldHint`**: `true` if the tool interacts with external entities (web APIs, databases), `false` for internal tools
|
|
400
|
+
|
|
401
|
+
**Example with annotations:**
|
|
402
|
+
```json
|
|
403
|
+
{
|
|
404
|
+
"name": "delete_resource",
|
|
405
|
+
"description": "Delete a resource from the remote server",
|
|
406
|
+
"annotations": {
|
|
407
|
+
"title": "Delete Resource",
|
|
408
|
+
"readOnlyHint": false,
|
|
409
|
+
"destructiveHint": true,
|
|
410
|
+
"idempotentHint": false,
|
|
411
|
+
"openWorldHint": true
|
|
412
|
+
},
|
|
413
|
+
"inputSchema": {
|
|
414
|
+
"type": "object",
|
|
415
|
+
"properties": {
|
|
416
|
+
"id": {"type": "string", "description": "Resource ID"}
|
|
417
|
+
},
|
|
418
|
+
"required": ["id"]
|
|
419
|
+
},
|
|
420
|
+
"execution": {
|
|
421
|
+
"type": "http",
|
|
422
|
+
"method": "DELETE",
|
|
423
|
+
"url": "{{env.API_URL}}/resources/{{props.id}}"
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
**Example with partial annotations:**
|
|
429
|
+
```json
|
|
430
|
+
{
|
|
431
|
+
"name": "read_data",
|
|
432
|
+
"description": "Read data from the database",
|
|
433
|
+
"annotations": {
|
|
434
|
+
"title": "Read Data",
|
|
435
|
+
"readOnlyHint": true
|
|
436
|
+
},
|
|
437
|
+
"execution": {
|
|
438
|
+
"type": "http",
|
|
439
|
+
"method": "GET",
|
|
440
|
+
"url": "{{env.API_URL}}/data"
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
> **Note**: Annotations are automatically included when serving tools via `uvx mcix run`. MCP clients can use these annotations for filtering, validation, and user interface enhancements.
|
|
446
|
+
|
|
447
|
+
### Text Execution
|
|
448
|
+
|
|
449
|
+
Returns templated text using `{{props.field}}` and `{{env.VAR}}` syntax.
|
|
450
|
+
|
|
451
|
+
**Example:**
|
|
452
|
+
```json
|
|
453
|
+
{
|
|
454
|
+
"name": "greet_user",
|
|
455
|
+
"description": "Greet a user by name",
|
|
456
|
+
"inputSchema": {
|
|
457
|
+
"type": "object",
|
|
458
|
+
"properties": {
|
|
459
|
+
"username": {
|
|
460
|
+
"type": "string",
|
|
461
|
+
"description": "Name of the user to greet"
|
|
462
|
+
}
|
|
463
|
+
},
|
|
464
|
+
"required": ["username"]
|
|
465
|
+
},
|
|
466
|
+
"execution": {
|
|
467
|
+
"type": "text",
|
|
468
|
+
"text": "Hello {{props.username}}! Welcome to MCI."
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
This tool takes a username as input and returns a personalized greeting message.
|
|
474
|
+
|
|
475
|
+
### File Execution
|
|
476
|
+
|
|
477
|
+
Reads and returns file contents, with optional templating support.
|
|
478
|
+
|
|
479
|
+
**Example:**
|
|
480
|
+
```json
|
|
481
|
+
{
|
|
482
|
+
"name": "read_config",
|
|
483
|
+
"description": "Read application configuration file",
|
|
484
|
+
"inputSchema": {
|
|
485
|
+
"type": "object",
|
|
486
|
+
"properties": {
|
|
487
|
+
"config_path": {
|
|
488
|
+
"type": "string",
|
|
489
|
+
"description": "Path to configuration file"
|
|
490
|
+
}
|
|
491
|
+
},
|
|
492
|
+
"required": ["config_path"]
|
|
493
|
+
},
|
|
494
|
+
"execution": {
|
|
495
|
+
"type": "file",
|
|
496
|
+
"path": "{{props.config_path}}",
|
|
497
|
+
"enableTemplating": false
|
|
498
|
+
},
|
|
499
|
+
"directoryAllowList": ["./configs", "/etc/myapp"]
|
|
500
|
+
}
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
This tool reads a configuration file from an allowed directory. The `directoryAllowList` ensures files can only be read from safe locations.
|
|
504
|
+
|
|
505
|
+
### CLI Execution
|
|
506
|
+
|
|
507
|
+
Executes command-line programs with arguments and flags.
|
|
508
|
+
|
|
509
|
+
**Example:**
|
|
510
|
+
```json
|
|
511
|
+
{
|
|
512
|
+
"name": "search_files",
|
|
513
|
+
"description": "Search for text in files using grep",
|
|
514
|
+
"inputSchema": {
|
|
515
|
+
"type": "object",
|
|
516
|
+
"properties": {
|
|
517
|
+
"pattern": {
|
|
518
|
+
"type": "string",
|
|
519
|
+
"description": "Search pattern"
|
|
520
|
+
},
|
|
521
|
+
"directory": {
|
|
522
|
+
"type": "string",
|
|
523
|
+
"description": "Directory to search in"
|
|
524
|
+
},
|
|
525
|
+
"ignore_case": {
|
|
526
|
+
"type": "boolean",
|
|
527
|
+
"description": "Ignore case in search"
|
|
528
|
+
}
|
|
529
|
+
},
|
|
530
|
+
"required": ["pattern", "directory"]
|
|
531
|
+
},
|
|
532
|
+
"execution": {
|
|
533
|
+
"type": "cli",
|
|
534
|
+
"command": "grep",
|
|
535
|
+
"args": ["-r", "-n", "{{props.pattern}}"],
|
|
536
|
+
"flags": {
|
|
537
|
+
"-i": {
|
|
538
|
+
"from": "props.ignore_case",
|
|
539
|
+
"type": "boolean"
|
|
540
|
+
}
|
|
541
|
+
},
|
|
542
|
+
"cwd": "{{props.directory}}",
|
|
543
|
+
"timeout_ms": 8000
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
This tool executes `grep` to search for text in files. The `-i` flag is conditionally added based on the `ignore_case` property.
|
|
549
|
+
|
|
550
|
+
### HTTP Execution
|
|
551
|
+
|
|
552
|
+
Makes HTTP requests to external APIs with full header and authentication support.
|
|
553
|
+
|
|
554
|
+
**Example:**
|
|
555
|
+
```json
|
|
556
|
+
{
|
|
557
|
+
"name": "get_weather",
|
|
558
|
+
"description": "Get current weather for a location",
|
|
559
|
+
"inputSchema": {
|
|
560
|
+
"type": "object",
|
|
561
|
+
"properties": {
|
|
562
|
+
"location": {
|
|
563
|
+
"type": "string",
|
|
564
|
+
"description": "City name or coordinates"
|
|
565
|
+
}
|
|
566
|
+
},
|
|
567
|
+
"required": ["location"]
|
|
568
|
+
},
|
|
569
|
+
"execution": {
|
|
570
|
+
"type": "http",
|
|
571
|
+
"method": "GET",
|
|
572
|
+
"url": "https://api.example.com/weather",
|
|
573
|
+
"params": {
|
|
574
|
+
"location": "{{props.location}}",
|
|
575
|
+
"units": "metric"
|
|
576
|
+
},
|
|
577
|
+
"headers": {
|
|
578
|
+
"Accept": "application/json",
|
|
579
|
+
"Authorization": "Bearer {{env.WEATHER_API_KEY}}"
|
|
580
|
+
},
|
|
581
|
+
"timeout_ms": 5000
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
This tool makes a GET request to a weather API, using an API key from the environment and the location from the input properties.
|
|
587
|
+
|
|
588
|
+
### MCP Execution
|
|
589
|
+
|
|
590
|
+
Invokes tools from other MCP servers (for tool composition and chaining).
|
|
591
|
+
|
|
592
|
+
**Example:**
|
|
593
|
+
```json
|
|
594
|
+
{
|
|
595
|
+
"name": "analyze_with_ai",
|
|
596
|
+
"description": "Analyze data using AI MCP server",
|
|
597
|
+
"inputSchema": {
|
|
598
|
+
"type": "object",
|
|
599
|
+
"properties": {
|
|
600
|
+
"data": {
|
|
601
|
+
"type": "string",
|
|
602
|
+
"description": "Data to analyze"
|
|
603
|
+
}
|
|
604
|
+
},
|
|
605
|
+
"required": ["data"]
|
|
606
|
+
},
|
|
607
|
+
"execution": {
|
|
608
|
+
"type": "mcp",
|
|
609
|
+
"server": "ai_analysis_server",
|
|
610
|
+
"tool": "analyze_text",
|
|
611
|
+
"arguments": {
|
|
612
|
+
"text": "{{props.data}}",
|
|
613
|
+
"model": "gpt-4"
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
This tool delegates execution to another MCP server's tool, enabling composition of complex workflows.
|
|
620
|
+
|
|
621
|
+
### Common Features
|
|
622
|
+
|
|
623
|
+
All execution types support:
|
|
624
|
+
- **Environment variable templating**: Use `{{env.VAR}}` to access environment variables
|
|
625
|
+
- **Property templating**: Use `{{props.field}}` to access input properties
|
|
626
|
+
- **Input validation**: Define schemas with JSON Schema for type safety
|
|
627
|
+
|
|
628
|
+
## Configuration Files
|
|
629
|
+
|
|
630
|
+
### Main Configuration (`mci.json` or `mci.yaml`)
|
|
631
|
+
|
|
632
|
+
```json
|
|
633
|
+
{
|
|
634
|
+
"schemaVersion": "1.0",
|
|
635
|
+
"metadata": {
|
|
636
|
+
"name": "My Project",
|
|
637
|
+
"description": "My MCI configuration"
|
|
638
|
+
},
|
|
639
|
+
"tools": [
|
|
640
|
+
{
|
|
641
|
+
"name": "example_tool",
|
|
642
|
+
"description": "Example tool",
|
|
643
|
+
"inputSchema": {
|
|
644
|
+
"type": "object",
|
|
645
|
+
"properties": {
|
|
646
|
+
"message": {"type": "string"}
|
|
647
|
+
}
|
|
648
|
+
},
|
|
649
|
+
"execution": {
|
|
650
|
+
"type": "text",
|
|
651
|
+
"text": "Echo: {{props.message}}"
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
],
|
|
655
|
+
"toolsets": ["my-toolset"],
|
|
656
|
+
"mcp_servers": {}
|
|
657
|
+
}
|
|
658
|
+
```
|
|
659
|
+
|
|
660
|
+
### Toolset Files (`mci/*.mci.json`)
|
|
661
|
+
|
|
662
|
+
Toolset files follow the same schema but typically contain focused collections of related tools.
|
|
663
|
+
|
|
664
|
+
## Environment Variables
|
|
665
|
+
|
|
666
|
+
MCI supports environment variable templating in tool definitions:
|
|
667
|
+
|
|
668
|
+
```json
|
|
669
|
+
{
|
|
670
|
+
"execution": {
|
|
671
|
+
"type": "http",
|
|
672
|
+
"url": "{{env.BASE_URL}}/api/endpoint",
|
|
673
|
+
"headers": {
|
|
674
|
+
"Authorization": "Bearer {{env.API_KEY}}"
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
### Automatic .env File Loading
|
|
681
|
+
|
|
682
|
+
MCI automatically loads environment variables from `.env` and `.env.mci` files when loading your MCI schema. This provides a convenient way to manage environment-specific configuration without manually setting variables.
|
|
683
|
+
|
|
684
|
+
**Automatic Detection:**
|
|
685
|
+
- When you run any MCI command (`run`, `list`, `validate`, etc.), MCI looks for environment files in:
|
|
686
|
+
1. The project root directory (same location as your `mci.json` or `mci.yaml`)
|
|
687
|
+
2. The `./mci` directory
|
|
688
|
+
|
|
689
|
+
**File Priority:**
|
|
690
|
+
- MCI prioritizes `.env.mci` files (MCI-specific configs) over `.env` files (general configs)
|
|
691
|
+
- **Important:** When `.env.mci` files exist, `.env` files are **not loaded** at all
|
|
692
|
+
- This allows you to keep MCI-specific environment variables separate from general project variables
|
|
693
|
+
|
|
694
|
+
**Loading Behavior:**
|
|
695
|
+
- **If `.env.mci` files exist:** Only `.env.mci` files are loaded
|
|
696
|
+
1. `./mci/.env.mci` - Library MCI-specific configs
|
|
697
|
+
2. Project root `.env.mci` - Project MCI-specific configs (higher priority)
|
|
698
|
+
- **If no `.env.mci` files exist:** `.env` files are loaded instead
|
|
699
|
+
1. `./mci/.env` - Library general defaults
|
|
700
|
+
2. Project root `.env` - Project-level configs (higher priority)
|
|
701
|
+
- **Then:** System environment variables and explicit env_vars override all file-based configs
|
|
702
|
+
|
|
703
|
+
**Full Precedence Order (lowest to highest):**
|
|
704
|
+
1. File-based configs (`.env.mci` files if they exist, otherwise `.env` files)
|
|
705
|
+
- From `./mci/` directory first
|
|
706
|
+
- Then from project root
|
|
707
|
+
2. System environment variables (set via `export` or shell config)
|
|
708
|
+
3. Environment variables passed via CLI or code (highest priority)
|
|
709
|
+
|
|
710
|
+
**Example .env file:**
|
|
711
|
+
```bash
|
|
712
|
+
# .env or .env.mci file in project root
|
|
713
|
+
API_KEY=your-api-key-here
|
|
714
|
+
BASE_URL=https://api.example.com
|
|
715
|
+
DEBUG=false
|
|
716
|
+
|
|
717
|
+
# Comments are supported
|
|
718
|
+
# Blank lines are ignored
|
|
719
|
+
|
|
720
|
+
# Export keyword is optional (automatically stripped)
|
|
721
|
+
export OPTIONAL_VAR=value
|
|
722
|
+
```
|
|
723
|
+
|
|
724
|
+
**Example directory structure:**
|
|
725
|
+
```
|
|
726
|
+
my-project/
|
|
727
|
+
├── .env.mci # MCI-specific variables (if present, .env ignored)
|
|
728
|
+
├── .env # General project variables (only if .env.mci absent)
|
|
729
|
+
├── mci.json # Your MCI schema
|
|
730
|
+
└── mci/
|
|
731
|
+
├── .env.mci # Library MCI-specific (if present, ./mci/.env ignored)
|
|
732
|
+
├── .env # Library defaults (only if ./mci/.env.mci absent)
|
|
733
|
+
└── weather.mci.json # Your toolsets
|
|
734
|
+
```
|
|
735
|
+
|
|
736
|
+
**Example: Using .env.mci files**
|
|
737
|
+
```bash
|
|
738
|
+
# Scenario 1: Only .env.mci files present
|
|
739
|
+
# ./mci/.env.mci
|
|
740
|
+
API_KEY=mci-library-key
|
|
741
|
+
LIBRARY_VAR=lib-value
|
|
742
|
+
|
|
743
|
+
# .env.mci (project root)
|
|
744
|
+
API_KEY=mci-project-key # Overrides ./mci/.env.mci
|
|
745
|
+
MCI_SPECIFIC=mci-value
|
|
746
|
+
|
|
747
|
+
# Result: MCI will use:
|
|
748
|
+
# API_KEY=mci-project-key (from root .env.mci)
|
|
749
|
+
# LIBRARY_VAR=lib-value (from ./mci/.env.mci)
|
|
750
|
+
# MCI_SPECIFIC=mci-value (from root .env.mci)
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
**Example: Using .env files (no .env.mci)**
|
|
754
|
+
```bash
|
|
755
|
+
# Scenario 2: Only .env files present
|
|
756
|
+
# ./mci/.env
|
|
757
|
+
API_KEY=default-key
|
|
758
|
+
LIBRARY_VAR=lib-value
|
|
759
|
+
|
|
760
|
+
# .env (project root)
|
|
761
|
+
API_KEY=project-key # Overrides ./mci/.env
|
|
762
|
+
PROJECT_VAR=proj-value
|
|
763
|
+
|
|
764
|
+
# Result: MCI will use:
|
|
765
|
+
# API_KEY=project-key (from root .env)
|
|
766
|
+
# LIBRARY_VAR=lib-value (from ./mci/.env)
|
|
767
|
+
# PROJECT_VAR=proj-value (from root .env)
|
|
768
|
+
```
|
|
769
|
+
|
|
770
|
+
**Notes:**
|
|
771
|
+
- .env files are completely optional - MCI works fine without them
|
|
772
|
+
- No error if .env files are missing
|
|
773
|
+
- Use `.env.mci` for MCI-specific configurations to keep them completely separate from general project configs
|
|
774
|
+
- When `.env.mci` exists, `.env` is ignored (not merged)
|
|
775
|
+
- You can disable auto-loading by setting `auto_load_dotenv=False` when using the MCI library programmatically
|
|
776
|
+
- .env files should NOT be committed to version control if they contain secrets
|
|
777
|
+
|
|
778
|
+
### Setting Environment Variables for MCP Clients
|
|
779
|
+
|
|
780
|
+
When running MCI as an MCP server from clients like Claude Desktop or VS Code, you have two options for environment variables:
|
|
781
|
+
|
|
782
|
+
1. **Use .env files** (recommended): Create a `.env` file in your project root, and MCI will automatically load it
|
|
783
|
+
2. **Configure in client settings**: Explicitly set environment variables in the MCP client configuration
|
|
784
|
+
|
|
785
|
+
**Option 1: Using .env files (Recommended)**
|
|
786
|
+
|
|
787
|
+
Create a `.env` file in your project root:
|
|
788
|
+
```bash
|
|
789
|
+
# .env
|
|
790
|
+
API_KEY=your-api-key
|
|
791
|
+
BASE_URL=https://api.example.com
|
|
792
|
+
```
|
|
793
|
+
|
|
794
|
+
Then configure your MCP client with minimal settings:
|
|
795
|
+
```json
|
|
796
|
+
{
|
|
797
|
+
"mcpServers": {
|
|
798
|
+
"mci-tools": {
|
|
799
|
+
"command": "uvx",
|
|
800
|
+
"args": ["mcix", "run"],
|
|
801
|
+
"cwd": "/path/to/your/project"
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
```
|
|
806
|
+
|
|
807
|
+
MCI will automatically load the `.env` file when it starts.
|
|
808
|
+
|
|
809
|
+
**Option 2: Configure in Client Settings**
|
|
810
|
+
|
|
811
|
+
**Claude Desktop Example** (`claude_desktop_config.json`):
|
|
812
|
+
```json
|
|
813
|
+
{
|
|
814
|
+
"mcpServers": {
|
|
815
|
+
"mci-tools": {
|
|
816
|
+
"command": "uvx",
|
|
817
|
+
"args": ["mcix", "run"],
|
|
818
|
+
"cwd": "/path/to/your/project",
|
|
819
|
+
"env": {
|
|
820
|
+
"API_KEY": "your-api-key",
|
|
821
|
+
"BASE_URL": "https://api.example.com",
|
|
822
|
+
"PROJECT_ROOT": "/path/to/your/project"
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
```
|
|
828
|
+
|
|
829
|
+
**VS Code Example** (`.vscode/settings.json`):
|
|
830
|
+
```json
|
|
831
|
+
{
|
|
832
|
+
"mcp.servers": {
|
|
833
|
+
"mci-tools": {
|
|
834
|
+
"command": "uvx",
|
|
835
|
+
"args": ["mcix", "run"],
|
|
836
|
+
"cwd": "${workspaceFolder}",
|
|
837
|
+
"env": {
|
|
838
|
+
"API_KEY": "your-api-key",
|
|
839
|
+
"BASE_URL": "https://api.example.com",
|
|
840
|
+
"PROJECT_ROOT": "${workspaceFolder}"
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
```
|
|
846
|
+
|
|
847
|
+
**Running Standalone** (without MCP client):
|
|
848
|
+
|
|
849
|
+
MCI automatically loads `.env` files from your project root and `./mci` directory:
|
|
850
|
+
|
|
851
|
+
```bash
|
|
852
|
+
# Create .env file
|
|
853
|
+
echo "API_KEY=your-api-key" > .env
|
|
854
|
+
echo "BASE_URL=https://api.example.com" >> .env
|
|
855
|
+
|
|
856
|
+
# Run MCI - it will automatically load .env
|
|
857
|
+
uvx mcix run
|
|
858
|
+
```
|
|
859
|
+
|
|
860
|
+
You can also set environment variables manually if needed:
|
|
861
|
+
```bash
|
|
862
|
+
export API_KEY=your-api-key
|
|
863
|
+
export BASE_URL=https://api.example.com
|
|
864
|
+
uvx mcix run
|
|
865
|
+
```
|
|
866
|
+
|
|
867
|
+
## Integration with MCP Clients
|
|
868
|
+
|
|
869
|
+
The `mcix run` command creates an MCP-compliant server that can be used with:
|
|
870
|
+
|
|
871
|
+
- **Claude Desktop**: Configure as an MCP server in settings
|
|
872
|
+
- **MCP CLI tools**: Connect via STDIO transport
|
|
873
|
+
- **Custom integrations**: Use the MCP Python SDK
|
|
874
|
+
|
|
875
|
+
Example Claude Desktop configuration:
|
|
876
|
+
|
|
877
|
+
```json
|
|
878
|
+
{
|
|
879
|
+
"mcpServers": {
|
|
880
|
+
"mci-tools": {
|
|
881
|
+
"command": "uvx",
|
|
882
|
+
"args": ["mcix", "run"],
|
|
883
|
+
"cwd": "/path/to/your/project"
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
```
|
|
888
|
+
|
|
889
|
+
## Documentation
|
|
890
|
+
|
|
891
|
+
- **[Development Guide](development.md)** - Setup, testing, and contribution workflow
|
|
892
|
+
- **[Technical Architecture](docs/architecture.md)** - Project structure and design decisions
|
|
893
|
+
- **[Implementation Plan](PLAN.md)** - Full development roadmap
|
|
894
|
+
- **[Product Requirements](PRD.md)** - Project goals and specifications
|
|
895
|
+
- **[Installation Guide](installation.md)** - Detailed installation instructions
|
|
896
|
+
- **[Publishing Guide](publishing.md)** - How to publish to PyPI
|
|
897
|
+
|
|
898
|
+
## Key Features
|
|
899
|
+
|
|
900
|
+
✨ **Declarative Tool Definitions** - Define tools once, use everywhere
|
|
901
|
+
|
|
902
|
+
🔌 **Multiple Execution Types** - Text, file, CLI, HTTP, and MCP support
|
|
903
|
+
|
|
904
|
+
🎯 **Flexible Filtering** - Filter by tags, names, or toolsets
|
|
905
|
+
|
|
906
|
+
📦 **Toolset Management** - Organize and reuse tool collections
|
|
907
|
+
|
|
908
|
+
🔄 **Dynamic MCP Servers** - Instantly turn MCI schemas into MCP servers
|
|
909
|
+
|
|
910
|
+
🌍 **Environment Templating** - Use environment variables in tool definitions
|
|
911
|
+
|
|
912
|
+
✅ **Built-in Validation** - Comprehensive schema validation
|
|
913
|
+
|
|
914
|
+
📊 **Multiple Output Formats** - JSON, YAML, and table displays
|
|
915
|
+
|
|
916
|
+
## Contributing
|
|
917
|
+
|
|
918
|
+
Contributions are welcome! Please see [development.md](development.md) for:
|
|
919
|
+
|
|
920
|
+
- Setting up your development environment
|
|
921
|
+
- Running tests and linters
|
|
922
|
+
- Building the project
|
|
923
|
+
- Submitting pull requests
|
|
924
|
+
|
|
925
|
+
## License
|
|
926
|
+
|
|
927
|
+
MIT License - see LICENSE file for details
|
|
928
|
+
|
|
929
|
+
---
|
|
930
|
+
|
|
931
|
+
*This project was built from [simple-modern-uv](https://github.com/jlevy/simple-modern-uv).*
|