Skip to content

Commit c0bede3

Browse files
committed
Updated README for consistency
1 parent e95aa0b commit c0bede3

File tree

1 file changed

+197
-96
lines changed

1 file changed

+197
-96
lines changed

README.md

Lines changed: 197 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
# @247arjun/mcp-jq
1+
# MCP Server for JQ
22

33
[![npm version](https://badge.fury.io/js/@247arjun%2Fmcp-jq.svg)](https://badge.fury.io/js/@247arjun%2Fmcp-jq)
4-
[![CI](https://github.com/247arjun/mcp-jq/workflows/CI/badge.svg)](https://github.com/247arjun/mcp-jq/actions)
5-
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6-
[![Node.js Version](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen.svg)](https://nodejs.org/)
7-
[![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue.svg)](https://www.typescriptlang.org/)
4+
[![npm downloads](https://img.shields.io/npm/dm/@247arjun/mcp-jq.svg)](https://www.npmjs.com/package/@247arjun/mcp-jq)
85

9-
An MCP (Model Context Protocol) server that provides a wrapper around the `jq` command-line utility for querying JSON data.
6+
A Model Context Protocol (MCP) server that provides a wrapper around the `jq` command-line utility for querying and manipulating JSON data.
107

118
## Features
129

13-
- Query JSON files using jq syntax
14-
- Parse and format JSON data
15-
- Support for complex jq filters and operations
16-
- Stream processing for large JSON files
10+
- **JSON Querying**: Query JSON files and data using jq syntax
11+
- **Data Formatting**: Parse and format JSON data
12+
- **Complex Operations**: Support for complex jq filters and operations
13+
- **File Processing**: Stream processing for large JSON files
14+
- **Validation**: JSON validation and key extraction
15+
- **Security**: Safe subprocess execution with input validation
1716

1817
## Prerequisites
1918

@@ -37,7 +36,7 @@ Download from https://jqlang.github.io/jq/download/
3736

3837
## Installation
3938

40-
### Option 1: Install from npm (Recommended)
39+
### Method 1: NPM Installation (Recommended)
4140

4241
```bash
4342
# Install globally
@@ -47,164 +46,266 @@ npm install -g @247arjun/mcp-jq
4746
npm install @247arjun/mcp-jq
4847
```
4948

50-
### Option 2: Install from source
49+
### Method 2: From Source
5150

52-
1. **Clone the repository:**
53-
```bash
54-
git clone https://github.com/247arjun/mcp-jq.git
55-
cd mcp-jq
56-
```
57-
58-
2. **Install dependencies:**
59-
```bash
60-
npm install
61-
```
51+
```bash
52+
# Clone the repository
53+
git clone https://github.com/247arjun/mcp-jq.git
54+
cd mcp-jq
6255

63-
3. **Build the project:**
64-
```bash
65-
npm run build
66-
```
56+
# Install dependencies
57+
npm install
6758

68-
4. **Run tests:**
69-
```bash
70-
npm test
71-
```
59+
# Build the project
60+
npm run build
7261

73-
5. **Start the server:**
74-
```bash
75-
npm start
76-
```
62+
# Optional: Link globally
63+
npm link
64+
```
7765

78-
### Option 3: Automated installation script
66+
### Method 3: Direct from GitHub
7967

8068
```bash
81-
chmod +x install.sh && ./install.sh
69+
# Install directly from GitHub
70+
npm install -g git+https://github.com/247arjun/mcp-jq.git
8271
```
8372

84-
## MCP Client Configuration
73+
## Configuration
74+
75+
### Claude Desktop Setup
8576

86-
### Using the npm-installed version (Recommended)
77+
Add to your Claude Desktop configuration file:
8778

88-
If you installed via npm globally:
79+
**Location:**
80+
- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
81+
- Windows: `%APPDATA%/Claude/claude_desktop_config.json`
8982

83+
**Configuration:**
9084
```json
9185
{
9286
"mcpServers": {
93-
"jq": {
87+
"mcp-jq": {
9488
"command": "mcp-jq",
95-
"description": "JSON querying with jq"
89+
"args": []
9690
}
9791
}
9892
}
9993
```
10094

101-
### Using the local build
102-
103-
If you built from source:
95+
**Alternative: Using npx (no global install needed)**
96+
```json
97+
{
98+
"mcpServers": {
99+
"mcp-jq": {
100+
"command": "npx",
101+
"args": ["@247arjun/mcp-jq"]
102+
}
103+
}
104+
}
105+
```
104106

107+
**Local Development Setup**
105108
```json
106109
{
107110
"mcpServers": {
108-
"jq": {
111+
"mcp-jq": {
109112
"command": "node",
110-
"args": ["/absolute/path/to/mcp-jq/build/index.js"],
111-
"description": "JSON querying with jq"
113+
"args": ["/absolute/path/to/mcp-jq/build/index.js"]
112114
}
113115
}
114116
}
115117
```
116118

117-
## Documentation
118-
119-
- **[EXAMPLES.md](EXAMPLES.md)** - Usage examples and advanced jq queries
120-
- **[INTEGRATION.md](INTEGRATION.md)** - Detailed integration guide for MCP clients
121-
122-
## Project Structure
123-
124-
```
125-
mcp-jq/
126-
├── src/
127-
│ └── index.ts # Main server implementation
128-
├── build/ # Compiled JavaScript (after build)
129-
├── examples/ # Sample JSON files for testing
130-
│ ├── users.json
131-
│ └── company.json
132-
├── package.json # Project dependencies and scripts
133-
├── tsconfig.json # TypeScript configuration
134-
├── install.sh # Installation script
135-
├── test.js # Test script
136-
└── README.md # This file
137-
```
119+
After adding the configuration, restart Claude Desktop to load the MCP server.
138120

139121
## Available Tools
140122

141-
The server exposes the following tools:
142-
143-
### `jq_query`
123+
### 1. `jq_query`
144124
Query JSON data using jq syntax.
145125

146126
**Parameters:**
147127
- `json_data` (string): The JSON data to query
148128
- `filter` (string): The jq filter expression
149-
- `raw_output` (boolean, optional): Return raw output instead of JSON
129+
- `raw_output` (boolean, optional): Return raw output instead of JSON (default: false)
150130

151-
### `jq_query_file`
131+
**Example:**
132+
```json
133+
{
134+
"json_data": "{\"users\": [{\"name\": \"John\", \"age\": 30}]}",
135+
"filter": ".users[0].name"
136+
}
137+
```
138+
139+
### 2. `jq_query_file`
152140
Query a JSON file using jq syntax.
153141

154142
**Parameters:**
155143
- `file_path` (string): Path to the JSON file
156144
- `filter` (string): The jq filter expression
157-
- `raw_output` (boolean, optional): Return raw output instead of JSON
145+
- `raw_output` (boolean, optional): Return raw output instead of JSON (default: false)
158146

159-
### `jq_format`
147+
**Example:**
148+
```json
149+
{
150+
"file_path": "./data/users.json",
151+
"filter": ".users | length"
152+
}
153+
```
154+
155+
### 3. `jq_format`
160156
Format and prettify JSON data.
161157

162158
**Parameters:**
163159
- `json_data` (string): The JSON data to format
164160

165-
### `jq_validate`
161+
**Example:**
162+
```json
163+
{
164+
"json_data": "{\"name\":\"John\",\"age\":30}"
165+
}
166+
```
167+
168+
### 4. `jq_validate`
166169
Validate if a string is valid JSON.
167170

168171
**Parameters:**
169172
- `json_data` (string): The JSON data to validate
170173

171-
### `jq_keys`
174+
**Example:**
175+
```json
176+
{
177+
"json_data": "{\"name\": \"John\", \"age\": 30}"
178+
}
179+
```
180+
181+
### 5. `jq_keys`
172182
Get all keys from a JSON object or array of objects.
173183

174184
**Parameters:**
175185
- `json_data` (string): The JSON data to extract keys from
176186
- `recursive` (boolean, optional): Get keys recursively (default: false)
177187

188+
**Example:**
189+
```json
190+
{
191+
"json_data": "{\"user\": {\"name\": \"John\", \"details\": {\"age\": 30}}}",
192+
"recursive": true
193+
}
194+
```
195+
196+
## Usage Examples
197+
198+
### Query user names from JSON
199+
```json
200+
{
201+
"tool": "jq_query",
202+
"json_data": "{\"users\": [{\"name\": \"John\"}, {\"name\": \"Jane\"}]}",
203+
"filter": ".users[].name"
204+
}
205+
```
206+
207+
### Format JSON data
208+
```json
209+
{
210+
"tool": "jq_format",
211+
"json_data": "{\"name\":\"John\",\"age\":30,\"city\":\"NYC\"}"
212+
}
213+
```
214+
215+
### Query a JSON file
216+
```json
217+
{
218+
"tool": "jq_query_file",
219+
"file_path": "./data/config.json",
220+
"filter": ".database.host"
221+
}
222+
```
223+
178224
## Development
179225

180-
Run in development mode with auto-rebuild:
226+
### Build and Run
181227
```bash
228+
# Development with auto-rebuild
182229
npm run dev
230+
231+
# Production build
232+
npm run build
233+
234+
# Start the server
235+
npm start
183236
```
184237

185-
## Contributing
238+
### Testing
239+
```bash
240+
# Run tests
241+
npm test
242+
```
186243

187-
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
244+
### Project Structure
188245

189-
1. Fork the repository
190-
2. Create a feature branch: `git checkout -b feature/your-feature`
191-
3. Make your changes and add tests
192-
4. Run tests: `npm test`
193-
5. Commit your changes: `git commit -am 'Add some feature'`
194-
6. Push to the branch: `git push origin feature/your-feature`
195-
7. Create a Pull Request
246+
```
247+
mcp-jq/
248+
├── src/
249+
│ └── index.ts # Main server implementation
250+
├── build/ # Compiled JavaScript (after build)
251+
├── examples/ # Sample JSON files for testing
252+
│ ├── users.json
253+
│ └── company.json
254+
├── package.json # Project dependencies and scripts
255+
├── tsconfig.json # TypeScript configuration
256+
├── install.sh # Installation script
257+
├── test.js # Test script
258+
└── README.md # This file
259+
```
196260

197-
## Changelog
261+
## Verification
198262

199-
See [CHANGELOG.md](CHANGELOG.md) for version history and changes.
263+
Test that the server is working:
200264

201-
## License
265+
```bash
266+
# Test the built server
267+
node build/index.js
202268

203-
MIT - see [LICENSE](LICENSE) for details.
269+
# Should show: "JQ MCP Server running on stdio"
270+
# Press Ctrl+C to exit
271+
```
272+
273+
## Troubleshooting
274+
275+
### Common Issues
276+
277+
1. **"Command not found" error**
278+
- Ensure mcp-jq is installed globally: `npm install -g @247arjun/mcp-jq`
279+
- Or use npx: `"command": "npx", "args": ["@247arjun/mcp-jq"]`
280+
281+
2. **"Permission denied" error**
282+
- Check file permissions: `chmod +x build/index.js`
283+
- Rebuild the project: `npm run build`
284+
285+
3. **MCP server not appearing in Claude**
286+
- Verify JSON syntax in configuration file
287+
- Restart Claude Desktop completely
288+
- Check that the command path is correct
289+
290+
4. **"jq command not found"**
291+
- Install jq on your system using the instructions above
292+
- Verify installation: `jq --version`
293+
294+
### Debugging
295+
296+
Enable verbose logging by setting environment variable:
297+
```bash
298+
# For development
299+
DEBUG=1 node build/index.js
300+
301+
# Test with sample input
302+
echo '{"jsonrpc": "2.0", "method": "initialize", "params": {}}' | node build/index.js
303+
```
204304

205-
## Support
305+
## Security Notes
206306

207-
- 📖 [Documentation](https://github.com/247arjun/mcp-jq#readme)
208-
- 🐛 [Bug Reports](https://github.com/247arjun/mcp-jq/issues/new?template=bug_report.yml)
209-
- 💡 [Feature Requests](https://github.com/247arjun/mcp-jq/issues/new?template=feature_request.yml)
210-
- 💬 [Discussions](https://github.com/247arjun/mcp-jq/discussions)
307+
- Safe subprocess execution using spawn instead of shell
308+
- Input validation for all jq commands and file paths
309+
- No arbitrary shell command execution
310+
- Path validation and sanitization for file operations
311+
- Input validation with Zod schemas

0 commit comments

Comments
 (0)