mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-18 00:03:23 +02:00
Minor updates to filesystem
This commit is contained in:
@@ -1,39 +1,37 @@
|
||||
# DuckDuckGo MCP Server
|
||||
|
||||
MCP server providing search functionality via DuckDuckGo's HTML interface.
|
||||
|
||||
## Core Concepts
|
||||
## Components
|
||||
|
||||
### Resources
|
||||
Single resource endpoint for search results:
|
||||
Single resource endpoint for search interface:
|
||||
```duckduckgo://search```
|
||||
|
||||
### Tools
|
||||
Search tool with configurable result count:
|
||||
```json
|
||||
{
|
||||
"name": "search",
|
||||
"arguments": {
|
||||
"query": "your search query",
|
||||
"numResults": 5 // optional, defaults to 5
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Implementation Details
|
||||
- HTML scraping via JSDOM
|
||||
- Clean result formatting with titles, snippets, and URLs
|
||||
- Error handling for network/parsing issues
|
||||
- Request rate limiting built-in via DuckDuckGo's interface
|
||||
- **duckduckgo_search**
|
||||
- Performs a search using DuckDuckGo and returns the top search results
|
||||
- Inputs:
|
||||
- `query` (string, required): The search query to look up
|
||||
- `numResults` (number, optional): Number of results to return (default: 10)
|
||||
- Returns titles, snippets, and URLs of the search results
|
||||
|
||||
## Usage Example
|
||||
```typescript
|
||||
// Search tool response format
|
||||
```javascript
|
||||
// Example tool call
|
||||
{
|
||||
content: [{
|
||||
type: "text",
|
||||
text: "Title: Example Result\nSnippet: Result description...\nURL: https://..."
|
||||
"name": "duckduckgo_search",
|
||||
"arguments": {
|
||||
"query": "your search query",
|
||||
"numResults": 10
|
||||
}
|
||||
}
|
||||
|
||||
// Example response format:
|
||||
{
|
||||
"content": [{
|
||||
"type": "text",
|
||||
"text": "Title: Result Title\nSnippet: Result description...\nURL: https://example.com\n\nTitle: Another Result\n..."
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
## Development
|
||||
Requires Node.js and npm. Uses ES modules.
|
||||
|
||||
@@ -16,7 +16,8 @@ const SEARCH_TOOL: Tool = {
|
||||
name: "duckduckgo_search",
|
||||
description:
|
||||
"Performs a search using DuckDuckGo and returns the top search results. " +
|
||||
"Returns titles, snippets, and URLs of the search results. ",
|
||||
"Returns titles, snippets, and URLs of the search results. " +
|
||||
"Use this tool to search for current information on the internet.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
"bin": {
|
||||
"mcp-server-duckduckgo": "dist/index.js"
|
||||
},
|
||||
"files": ["dist"],
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsc && shx chmod +x dist/*.js",
|
||||
"prepare": "npm run build",
|
||||
@@ -18,13 +20,13 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/sdk": "0.5.0",
|
||||
"jsdom": "^24.0.0",
|
||||
"jsdom": "^24.1.3",
|
||||
"node-fetch": "^3.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"shx": "^0.3.4",
|
||||
"typescript": "^5.6.2",
|
||||
"@types/jsdom": "^21.1.6",
|
||||
"@types/node": "^20.10.0"
|
||||
"@types/node": "^20.10.0",
|
||||
"shx": "^0.3.4",
|
||||
"typescript": "^5.6.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,20 +10,6 @@ Node.js server implementing Model Context Protocol (MCP) for filesystem operatio
|
||||
- Search files
|
||||
- Get file metadata
|
||||
|
||||
## Usage
|
||||
|
||||
1. Install dependencies:
|
||||
```
|
||||
npm install @modelcontextprotocol/sdk
|
||||
```
|
||||
|
||||
2. Run server:
|
||||
```
|
||||
node index.js
|
||||
```
|
||||
|
||||
3. Server runs on stdio, communicate using MCP.
|
||||
|
||||
## API
|
||||
|
||||
### Resources
|
||||
@@ -32,24 +18,66 @@ Node.js server implementing Model Context Protocol (MCP) for filesystem operatio
|
||||
|
||||
### Tools
|
||||
|
||||
1. `read_file`: Read file contents
|
||||
2. `read_multiple_files`: Read multiple files
|
||||
3. `write_file`: Create/overwrite file
|
||||
4. `create_directory`: Create directory
|
||||
5. `list_directory`: List directory contents
|
||||
6. `delete_file`: Delete file/directory
|
||||
7. `move_file`: Move/rename file/directory
|
||||
8. `search_files`: Search files/directories
|
||||
9. `get_file_info`: Get file metadata
|
||||
- **read_file**
|
||||
- Read complete contents of a file
|
||||
- Input: `path` (string)
|
||||
- Reads complete file contents with UTF-8 encoding
|
||||
|
||||
## Implementation
|
||||
- **read_multiple_files**
|
||||
- Read multiple files simultaneously
|
||||
- Input: `paths` (string[])
|
||||
- Failed reads won't stop the entire operation
|
||||
|
||||
- Uses `@modelcontextprotocol/sdk`
|
||||
- Async file operations with `fs/promises`
|
||||
- Type guards for argument validation
|
||||
- Error handling and detailed descriptions
|
||||
- **write_file**
|
||||
- Create new file or overwrite existing
|
||||
- Inputs:
|
||||
- `path` (string): File location
|
||||
- `content` (string): File content
|
||||
|
||||
- **create_directory**
|
||||
- Create new directory or ensure it exists
|
||||
- Input: `path` (string)
|
||||
- Creates parent directories if needed
|
||||
- Succeeds silently if directory exists
|
||||
|
||||
- **list_directory**
|
||||
- List directory contents with [FILE] or [DIR] prefixes
|
||||
- Input: `path` (string)
|
||||
|
||||
- **delete_file**
|
||||
- Remove files or directories
|
||||
- Inputs:
|
||||
- `path` (string)
|
||||
- `recursive` (boolean, optional): For directory deletion
|
||||
- Use with caution - deletions are permanent
|
||||
|
||||
- **move_file**
|
||||
- Move or rename files and directories
|
||||
- Inputs:
|
||||
- `source` (string)
|
||||
- `destination` (string)
|
||||
- Fails if destination exists
|
||||
|
||||
- **search_files**
|
||||
- Recursively search for files/directories
|
||||
- Inputs:
|
||||
- `path` (string): Starting directory
|
||||
- `pattern` (string): Search pattern
|
||||
- Case-insensitive matching
|
||||
- Returns full paths to matches
|
||||
|
||||
- **get_file_info**
|
||||
- Get detailed file/directory metadata
|
||||
- Input: `path` (string)
|
||||
- Returns:
|
||||
- Size
|
||||
- Creation time
|
||||
- Modified time
|
||||
- Access time
|
||||
- Type (file/directory)
|
||||
- Permissions
|
||||
|
||||
## Notes
|
||||
|
||||
- Careful with `delete_file` and `write_file` (overwrites existing)
|
||||
- Exercise caution with `delete_file` (deletes files permanently) and `write_file` (overwrites existing files)
|
||||
- File paths can be absolute or relative
|
||||
|
||||
@@ -153,7 +153,6 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
||||
name: "write_file",
|
||||
description:
|
||||
"Create a new file or completely overwrite an existing file with new content. " +
|
||||
"This tool will create any necessary parent directories automatically. " +
|
||||
"Use with caution as it will overwrite existing files without warning. " +
|
||||
"Handles text content with proper encoding.",
|
||||
inputSchema: {
|
||||
|
||||
Reference in New Issue
Block a user