### Install snf-mcp and Dependencies Source: https://context7.com/mseri/snf-mcp/llms.txt Build the snf-mcp server from source using OPAM and Dune. Optionally install trafilatura for enhanced Markdown extraction. ```bash git clone https://github.com/mseri/snf-mcp cd snf-mcp opam install . --deps-only dune build dune install # places 'snf-mcp' on your PATH # Optional: install trafilatura for higher-quality Markdown extraction uv tool install trafilatura # or: pipx install trafilatura ``` -------------------------------- ### Start snf-mcp Server in Standard I/O Mode Source: https://github.com/mseri/snf-mcp/blob/main/README.md Run this command to start the snf-mcp server using standard input and output. This mode is suitable for integration with LLM clients or other processes that communicate via stdin/stdout. ```bash dune exec snf-mcp ``` -------------------------------- ### snf-mcp Tool Schema Example Source: https://context7.com/mseri/snf-mcp/llms.txt Example JSON response detailing the available MCP tools, their descriptions, and input schemas. This is returned when querying the 'tools/list' method. ```json { "jsonrpc": "2.0", "id": 1, "result": { "tools": [ { "name": "fetch_markdown", "description": "Fetch and parse content from a webpage URL as Markdown, preserving links and formatting.", "inputSchema": { "type": "object", "properties": { "url": { "type": "string", "description": "The webpage URL to fetch content from" }, "max_length": { "type": "integer", "description": "Maximum length (in bytes) of content to return (default: 8192 characters). Use -1 to disable the limit." }, "start_from": { "type": "integer", "description": "Byte offset to start returning content from (default: 0)" } }, "required": ["url"] } }, { "name": "fetch_content", "description": "Fetch content from a webpage URL, stripping it of unnecessary html tags.", "inputSchema": { "...": "same shape as fetch_markdown" } }, { "name": "search_wikipedia", "description": "Search Wikipedia and return results...", "inputSchema": { "type": "object", "properties": { "query": { "type": "string", "description": "The search query string" }, "max_results": { "type": "integer", "description": "Maximum number of results to return (default: 10)" } }, "required": ["query"] } }, { "name": "search", "description": "Search DuckDuckGo and return results...", "inputSchema": { "...": "same shape as search_wikipedia" } } ] } } ``` -------------------------------- ### Install Trafilatura for Content Extraction Source: https://github.com/mseri/snf-mcp/blob/main/README.md Commands to install the 'trafilatura' Python library, which enhances text extraction quality for the fetch_markdown tool. ```bash uv tool install trafilatura # Method 1: Using `uv` tool ``` ```bash pipx install trafilatura # Method 2: Using `pipx` ``` ```bash pip install trafilatura # Method 3: Using `pip` ``` -------------------------------- ### Test: Fetch Webpage Content via HTTP Source: https://github.com/mseri/snf-mcp/blob/main/README.md Retrieve content from a webpage using the 'fetch_content' tool. This example fetches content from 'https://ocaml.org' by sending a POST request to the snf-mcp server. ```bash curl -X POST http://localhost:8080 -H "Content-Type: application/json" -d '{ "jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": { "name": "fetch_content", "arguments": { "url": "https://ocaml.org" } } }' ``` -------------------------------- ### Start snf-mcp Server in HTTP Mode Source: https://github.com/mseri/snf-mcp/blob/main/README.md Execute this command to start the snf-mcp server in HTTP mode, listening on port 3000. This is useful for external clients to interact with the server. ```bash dune exec snf-mcp -- --serve 3000 ``` -------------------------------- ### Test: Perform a Search via HTTP Source: https://github.com/mseri/snf-mcp/blob/main/README.md Execute a web search using the 'search' tool by sending a POST request to the snf-mcp server. This example searches for 'OCaml programming language' and requests a maximum of 3 results. ```bash curl -X POST http://localhost:8080 -H "Content-Type: application/json" -d '{ "jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": { "name": "search", "arguments": { "query": "OCaml programming language", "max_results": 3 } } }' ``` -------------------------------- ### Start snf-mcp Server for Testing Source: https://github.com/mseri/snf-mcp/blob/main/README.md Initiate the snf-mcp server on port 8080 to allow testing via HTTP requests. This command is used before sending `curl` commands to interact with the server. ```bash dune exec snf-mcp --serve 8080 ``` -------------------------------- ### snf_mcp Command-Line Options Source: https://github.com/mseri/snf-mcp/blob/main/README.md This displays the available command-line options for the snf_mcp binary when installed via OPAM. Options include running as an HTTP server (--serve), using stdio (--stdio), and logging control (--debug, --verbose, --quiet). ```bash snf_mcp [--serve PORT | --stdio] --serve Run http server, listening on PORT --stdio Use stdio for communication instead of port (default) --debug Enable debug logging --verbose Enable verbose logging --quiet Suppress non-error logs (default) -help Display this list of options --help Display this list of options ``` -------------------------------- ### Fetch webpage content via HTTP Source: https://context7.com/mseri/snf-mcp/llms.txt Demonstrates fetching webpage content using the 'fetch_content' tool via HTTP POST requests. Supports specifying max length and starting offset for pagination. ```bash curl -s -X POST http://localhost:8080 \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 4, "method": "tools/call", "params": { "name": "fetch_content", "arguments": { "url": "https://ocaml.org", "max_length": 4096 } } }' | jq .result.content[0].text ``` ```bash curl -s -X POST http://localhost:8080 \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 5, "method": "tools/call", "params": { "name": "fetch_content", "arguments": { "url": "https://ocaml.org", "start_from": 8192, "max_length": 8192 } } }' | jq .result.content[0].text ``` -------------------------------- ### Test: Fetch Webpage Content as Markdown via HTTP Source: https://github.com/mseri/snf-mcp/blob/main/README.md Retrieve webpage content formatted as Markdown using the 'fetch_markdown' tool. This example fetches from 'https://ocaml.org' via a POST request to the snf-mcp server. ```bash curl -X POST http://localhost:8080 -H "Content-Type: application/json" -d '{ "jsonrpc": "2.0", "id": 5, "method": "tools/call", "params": { "name": "fetch_markdown", "arguments": { "url": "https://ocaml.org" } } }' ``` -------------------------------- ### Run snf-mcp in stdio mode Source: https://context7.com/mseri/snf-mcp/llms.txt Start the snf-mcp server to communicate via standard input and output, suitable for direct integration with LLM clients. This is the default mode. ```bash snf-mcp --stdio # or, while developing: dune exec snf-mcp ``` -------------------------------- ### Run snf-mcp as an HTTP server Source: https://context7.com/mseri/snf-mcp/llms.txt Start the snf-mcp server to listen on a specified port for HTTP/JSON-RPC communication. Useful for remote access or integration with web applications. ```bash snf-mcp --serve 8080 # or, while developing: dune exec snf-mcp -- --serve 8080 ``` -------------------------------- ### Search DuckDuckGo using snf-mcp Source: https://context7.com/mseri/snf-mcp/llms.txt Example of how to use the 'search' MCP tool to query DuckDuckGo. This tool is rate-limited and includes automatic retries for anti-bot measures. ```bash # Example usage for the 'search' tool would go here, but is not provided in the source. ``` -------------------------------- ### Test: Search Wikipedia via HTTP Source: https://github.com/mseri/snf-mcp/blob/main/README.md Perform a Wikipedia search using the 'search_wikipedia' tool. This example searches for 'OCaml programming language' with a maximum of 3 results, sent via a POST request to the snf-mcp server. ```bash curl -X POST http://localhost:8080 -H "Content-Type: application/json" -d '{ "jsonrpc": "2.0", "id": 4, "method": "tools/call", "params": { "name": "search_wikipedia", "arguments": { "query": "OCaml programming language", "max_results": 3 } } }' ``` -------------------------------- ### MCP Server HTTP Mode with CORS Source: https://context7.com/mseri/snf-mcp/llms.txt Commands to start the `snf-mcp` server in HTTP mode with custom Cross-Origin Resource Sharing (CORS) configurations. ```bash # Allow a specific frontend origin snf-mcp --serve 8080 --cors "https://myapp.example.com" # Allow multiple origins snf-mcp --serve 8080 --cors "https://app1.example.com,http://localhost:3000" # Disable CORS entirely (trusted internal network only) snf-mcp --serve 8080 --cors off ``` -------------------------------- ### Build SNF MCP from Source Source: https://github.com/mseri/snf-mcp/blob/main/README.md Steps to build the snf-mcp binary from source. Ensure you are in the 'snf_mcp' directory after cloning. ```bash $ cd snf_mcp $ opam install . --deps-only $ dune build $ dune install ``` -------------------------------- ### List Tools via Stdio Source: https://github.com/mseri/snf-mcp/blob/main/README.md Use this command to list available tools by piping a JSON-RPC request to the snf-mcp binary. ```bash echo '{"jsonrpc":"2.0","method":"tools/list","id":1}' | dune exec snf-mcp | jq ``` -------------------------------- ### Test: List Available Tools via HTTP Source: https://github.com/mseri/snf-mcp/blob/main/README.md Send a POST request to the running snf-mcp server to list all available tools. This uses the MCP protocol's 'tools/list' method. ```bash curl -X POST http://localhost:8080 -H "Content-Type: application/json" -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/list" }' ``` -------------------------------- ### Call search tool via HTTP and stdio Source: https://context7.com/mseri/snf-mcp/llms.txt Demonstrates how to call the 'search' tool using both HTTP POST requests and stdio mode with snf-mcp. The output is piped to jq for parsing. ```bash curl -s -X POST http://localhost:8080 \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": { "name": "search", "arguments": { "query": "OCaml programming language", "max_results": 3 } } }' | jq . ``` ```bash echo '{ "jsonrpc":"2.0", "method":"tools/call", "params":{"name":"search","arguments":{"query":"OCaml programming language","max_results":3}}, "id":2 }' | snf-mcp --stdio | jq . ``` -------------------------------- ### Fetch entire webpage content via stdio Source: https://context7.com/mseri/snf-mcp/llms.txt Illustrates fetching the entire content of a webpage using the 'fetch_content' tool via stdio mode with snf-mcp. Setting max_length to -1 disables the byte limit. ```bash echo '{ "jsonrpc":"2.0", "method":"tools/call", "params":{"name":"fetch_content","arguments":{"url":"https://ocaml.org","max_length":-1}}, "id":4 }' | snf-mcp --stdio | jq .result.content[0].text ``` -------------------------------- ### Fetch Content via Stdio Source: https://github.com/mseri/snf-mcp/blob/main/README.md Retrieve content from a URL using the 'fetch_content' tool by piping a JSON-RPC request to the snf-mcp binary. ```bash echo '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"fetch_content","arguments":{"url":"https://ocaml.org"}},"id":4}' | dune exec snf-mcp | jq ``` -------------------------------- ### Fetch Markdown via Stdio Source: https://github.com/mseri/snf-mcp/blob/main/README.md Fetch content as Markdown from a URL using the 'fetch_markdown' tool by piping a JSON-RPC request to the snf-mcp binary. ```bash echo '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"fetch_markdown","arguments":{"url":"https://ocaml.org"}},"id":5}' | dune exec snf-mcp | jq ``` -------------------------------- ### Call Search Tool via Stdio Source: https://github.com/mseri/snf-mcp/blob/main/README.md Execute a search query using the 'search' tool by piping a JSON-RPC request to the snf-mcp binary. ```bash echo '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"search","arguments":{"query":"OCaml programming language"}},"id":2}' | dune exec snf-mcp | jq ``` -------------------------------- ### Fetch Content Parameters Source: https://github.com/mseri/snf-mcp/blob/main/README.md Configure parameters for fetching webpage content. Specify the 'url', and optionally set 'max_length' and 'start_from' for content retrieval control. Set 'max_length' to -1 to disable length limits. ```json { "url": "https://example.com/article", "max_length": 16384, "start_from": 1024 } ``` -------------------------------- ### MCP Client Integration Source: https://context7.com/mseri/snf-mcp/llms.txt Instructions on how to integrate the MCP tool with various LLM clients like LLM CLI, LMStudio, and Jan. ```APIDOC ## MCP Client Integration ### LLM CLI (`llm-tools-mcp` plugin) ```bash llm install llm-tools-mcp ``` `~/.llm-tools-mcp/mcp.json`: ```json { "mcpServers": { "snf_mcp": { "command": "/path/to/snf-mcp", "args": ["--stdio"] } } } ``` ### LMStudio Add the same JSON block above via **Settings → Plugins → MCP Servers**. See the [LMStudio MCP docs](https://lmstudio.ai/docs/app/plugins/mcp). ### Jan Set the full path to `snf-mcp` as the command and `--stdio` as the only argument. See the [Jan MCP docs](https://jan.ai/docs/mcp). ### HTTP mode with custom CORS ```bash # Allow a specific frontend origin snf-mcp --serve 8080 --cors "https://myapp.example.com" # Allow multiple origins snf-mcp --serve 8080 --cors "https://app1.example.com,http://localhost:3000" # Disable CORS entirely (trusted internal network only) snf-mcp --serve 8080 --cors off ``` ``` -------------------------------- ### List MCP Tools via stdio Source: https://context7.com/mseri/snf-mcp/llms.txt Send a JSON-RPC request to the snf-mcp server over stdio to retrieve the schema of all registered tools. Requires `jq` for pretty-printing the output. ```bash echo '{"jsonrpc":"2.0","method":"tools/list","id":1}' | snf-mcp --stdio | jq ``` -------------------------------- ### fetch_markdown Tool Source: https://context7.com/mseri/snf-mcp/llms.txt Fetches a webpage and returns it as clean Markdown, preserving links and formatting. It prefers `trafilatura` for high-quality extraction or falls back to the Jina Reader proxy service. The tool is rate-limited to 20 requests per minute. ```APIDOC ## fetch_markdown ### Description Fetch a webpage and return it as clean Markdown, preserving links and formatting. Prefers `trafilatura` (if installed) for high-quality extraction; otherwise falls back to the [Jina Reader](https://r.jina.ai/) proxy service. When using Jina Reader, the `start_from` offset is sent as an HTTP `Range` header; if the server does not support range requests, the offset is applied client-side. Rate-limited to 20 requests per minute (shared bucket with `fetch_content`). ### Parameters #### Query Parameters - **url** (string) - Required - Target URL - **max_length** (integer) - Optional - Byte limit on returned content; `-1` disables the limit. Default: 8192 - **start_from** (integer) - Optional - Byte offset to begin reading from. Default: 0 ### Request Example ```bash # HTTP mode — fetch as Markdown with full content curl -s -X POST http://localhost:8080 \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 6, "method": "tools/call", "params": { "name": "fetch_markdown", "arguments": { "url": "https://ocaml.org", "max_length": -1 } } }' | jq -r .result.content[0].text # Paginate through a long article (chunks of 16 KB) curl -s -X POST http://localhost:8080 \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 7, "method": "tools/call", "params": { "name": "fetch_markdown", "arguments": { "url": "https://en.wikipedia.org/wiki/OCaml", "start_from": 16384, "max_length": 16384 } } }' | jq -r .result.content[0].text # stdio mode echo '{ "jsonrpc":"2.0", "method":"tools/call", "params":{"name":"fetch_markdown","arguments":{"url":"https://ocaml.org"}}, "id":5 }' | snf-mcp --stdio | jq -r .result.content[0].text ``` ``` -------------------------------- ### MCP Client Configuration (llm-tools-mcp) Source: https://context7.com/mseri/snf-mcp/llms.txt Configuration for the `llm-tools-mcp` plugin to connect to an `snf-mcp` server via stdio. ```json { "mcpServers": { "snf_mcp": { "command": "/path/to/snf-mcp", "args": ["--stdio"] } } } ``` -------------------------------- ### Fetch Markdown via Stdio Source: https://context7.com/mseri/snf-mcp/llms.txt Use this command for stdio mode to fetch Markdown content. It pipes JSON-RPC requests to `snf-mcp` and processes the output with `jq`. ```bash # stdio mode echo '{ "jsonrpc":"2.0", "method":"tools/call", "params":{"name":"fetch_markdown","arguments":{"url":"https://ocaml.org"}}, "id":5 }' | snf-mcp --stdio | jq -r .result.content[0].text ``` -------------------------------- ### snf-mcp CLI Reference Source: https://context7.com/mseri/snf-mcp/llms.txt Overview of available command-line options for configuring the snf-mcp server, including transport mode, CORS policy, and logging levels. ```bash snf-mcp [--serve PORT | --stdio] [--cors off|localhost|ORIGINS] [--debug | --verbose | --quiet] --serve PORT Listen on PORT (HTTP/JSON-RPC mode) --stdio Read from stdin / write to stdout (default) --cors CORS policy: 'off', 'localhost' (default), or comma-separated origin list, e.g. 'https://example.com,http://localhost:3000' --debug Enable debug-level logging --verbose Enable info-level logging --quiet Suppress non-error logs (default) ``` -------------------------------- ### Rate Limiter Usage in OCaml Source: https://context7.com/mseri/snf-mcp/llms.txt Demonstrates how to create and use a rate limiter in OCaml. The `Rate_limiter.acquire` function blocks if the quota is exhausted. ```ocaml (* Internal usage — shown here for library consumers *) (* Create a limiter allowing 30 requests per minute *) let search_rl = Rate_limiter.create 30 (* Create a limiter allowing 20 requests per minute *) let fetch_rl = Rate_limiter.create 20 (* Acquire a slot before making a network request. Blocks the current Eio fiber if the quota is exhausted. *) Eio_main.run @@ fun env -> let clock = Eio.Stdenv.clock env in Rate_limiter.acquire search_rl clock; (* ... make the HTTP request ... *) ``` -------------------------------- ### List available tools Source: https://github.com/mseri/snf-mcp/blob/main/README.md Retrieves a list of all available tools that can be called on the MCP server. ```APIDOC ## POST /tools/list ### Description Lists all available tools on the MCP server. ### Method POST ### Endpoint / ### Request Body - **jsonrpc** (string) - Required - The JSON-RPC version, must be "2.0". - **id** (integer) - Required - The request ID. - **method** (string) - Required - The method name, must be "tools/list". ### Request Example ```json { "jsonrpc": "2.0", "id": 1, "method": "tools/list" } ``` ### Response #### Success Response (200) - **jsonrpc** (string) - The JSON-RPC version. - **id** (integer) - The request ID. - **result** (array) - An array of tool names. - **item** (string) - The name of a tool. #### Response Example ```json { "jsonrpc": "2.0", "id": 1, "result": [ "search", "search_wikipedia", "fetch_content", "fetch_markdown" ] } ``` ``` -------------------------------- ### Fetch Markdown via HTTP Source: https://context7.com/mseri/snf-mcp/llms.txt Use this command to fetch a webpage as Markdown. The `max_length` parameter controls the byte limit of the returned content. ```bash # HTTP mode — fetch as Markdown with full content curl -s -X POST http://localhost:8080 \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 6, "method": "tools/call", "params": { "name": "fetch_markdown", "arguments": { "url": "https://ocaml.org", "max_length": -1 } } }' | jq -r .result.content[0].text ``` -------------------------------- ### Call a tool Source: https://github.com/mseri/snf-mcp/blob/main/README.md Executes a specified tool with the provided arguments. ```APIDOC ## POST /tools/call ### Description Calls a specific tool with the given arguments. ### Method POST ### Endpoint / ### Parameters #### Request Body - **jsonrpc** (string) - Required - The JSON-RPC version, must be "2.0". - **id** (integer) - Required - The request ID. - **method** (string) - Required - The method name, must be "tools/call". - **params** (object) - Required - Parameters for the tool call. - **name** (string) - Required - The name of the tool to call. - **arguments** (object) - Required - The arguments to pass to the tool. ### Request Example ```json { "jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": { "name": "search", "arguments": { "query": "OCaml programming language", "max_results": 3 } } } ``` ### Response #### Success Response (200) - **jsonrpc** (string) - The JSON-RPC version. - **id** (integer) - The request ID. - **result** (any) - The result of the tool call. The structure depends on the tool called. #### Response Example (for search tool) ```json { "jsonrpc": "2.0", "id": 2, "result": [ { "title": "OCaml - Wikipedia", "url": "https://en.wikipedia.org/wiki/OCaml", "snippet": "OCaml is a general-purpose, industrial-strength programming language with support for object-oriented, imperative, functional and generic programming paradigms..." }, { "title": "OCaml - Wikipedia", "url": "https://en.wikipedia.org/wiki/OCaml", "snippet": "OCaml is a general-purpose, industrial-strength programming language with support for object-oriented, imperative, functional and generic programming paradigms..." }, { "title": "OCaml - Wikipedia", "url": "https://en.wikipedia.org/wiki/OCaml", "snippet": "OCaml is a general-purpose, industrial-strength programming language with support for object-oriented, imperative, functional and generic programming paradigms..." } ] } ``` ``` -------------------------------- ### List MCP Tools via HTTP Source: https://context7.com/mseri/snf-mcp/llms.txt Send a JSON-RPC request to the snf-mcp server over HTTP to retrieve the schema of all registered tools. Requires `jq` for pretty-printing the output. ```bash curl -s -X POST http://localhost:8080 \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | jq ``` -------------------------------- ### Paginate Fetch Markdown via HTTP Source: https://context7.com/mseri/snf-mcp/llms.txt Fetch content in chunks by specifying `start_from` and `max_length` to paginate through long articles. This is useful for processing large documents efficiently. ```bash # Paginate through a long article (chunks of 16 KB) curl -s -X POST http://localhost:8080 \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 7, "method": "tools/call", "params": { "name": "fetch_markdown", "arguments": { "url": "https://en.wikipedia.org/wiki/OCaml", "start_from": 16384, "max_length": 16384 } } }' | jq -r .result.content[0].text ``` -------------------------------- ### Configure LLM CLI for SNF MCP Source: https://github.com/mseri/snf-mcp/blob/main/README.md Configuration for the 'llm-tools-mcp' plugin to connect to the local snf-mcp server via stdio. ```json { "mcpServers": { "snf_mcp": { "command": "/path/to/snf-mcp", "args": [ "--stdio" ] } } } ``` -------------------------------- ### Call search_wikipedia tool via HTTP and stdio Source: https://context7.com/mseri/snf-mcp/llms.txt Shows how to use the 'search_wikipedia' tool via HTTP and stdio. This tool queries Wikipedia and returns structured results. The output is processed with jq. ```bash curl -s -X POST http://localhost:8080 \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": { "name": "search_wikipedia", "arguments": { "query": "functional programming", "max_results": 2 } } }' | jq .result.content[0].text ``` ```bash echo '{ "jsonrpc":"2.0", "method":"tools/call", "params":{"name":"search_wikipedia","arguments":{"query":"functional programming","max_results":2}}, "id":3 }' | snf-mcp --stdio | jq .result.content[0].text ``` -------------------------------- ### MCP Tool: fetch_content Source: https://context7.com/mseri/snf-mcp/llms.txt Fetch a webpage and return its text content with specific HTML elements stripped. Follows redirects and is rate-limited. ```APIDOC ## MCP Tool: `fetch_content` Fetch a webpage and return its text content with `