|
| 1 | +# Running a simple MCP Server |
| 2 | + |
| 3 | +The **[DuckDuckGo MCP server](https://hub.docker.com/mcp/server/duckduckgo/overview)** is a great MCP server that is very easy to use. |
| 4 | + |
| 5 | +Specifically, it provides two tools: |
| 6 | + |
| 7 | +1. **fetch_content** - fetch and parse content from a webpage URL |
| 8 | +2. **search** - search DuckDuckGo and return formatted results |
| 9 | + |
| 10 | +With these tools, you could create agents that can perform online searches, do basic research, and more! |
| 11 | + |
| 12 | + |
| 13 | +## Starting a MCP Gateway to use DuckDuckGo |
| 14 | + |
| 15 | +1. Create a `compose.yaml` file with the following contents: |
| 16 | + |
| 17 | + ```yaml save-as=compose.yaml |
| 18 | + services: |
| 19 | + gateway: |
| 20 | + image: docker/mcp-gateway |
| 21 | + command: |
| 22 | + - --servers=duckduckgo |
| 23 | + - --transport=streaming |
| 24 | + ports: |
| 25 | + - 8811:8811 |
| 26 | + volumes: |
| 27 | + - /var/run/docker.sock:/var/run/docker.sock |
| 28 | + ``` |
| 29 | +
|
| 30 | + To explain the flags: |
| 31 | +
|
| 32 | + - `--servers=duckduckgo` - configure the MCP Gateway to use the duckduckgo server from the Docker MCP Catalog |
| 33 | + - `--transport=streaming` - configure the MCP Gateway to use the [Streamable HTTP transport](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#streamable-http) |
| 34 | + - `/var/run/docker.sock:/var/run/docker.sock` - mount the Docker socket, which is required to actually launch the DuckDuckGo MCP server |
| 35 | + |
| 36 | + |
| 37 | +2. Start the gateway using Docker Compose: |
| 38 | + |
| 39 | + ```bash terminal-id=compose |
| 40 | + docker compose up |
| 41 | + ``` |
| 42 | + |
| 43 | + In the log output, you should see output similar to the following: |
| 44 | + |
| 45 | + ```plaintext no-copy-button |
| 46 | + gateway-1 | - Reading configuration... |
| 47 | + gateway-1 | - Reading catalog from [https://desktop.docker.com/mcp/catalog/v2/catalog.yaml] |
| 48 | + gateway-1 | - Configuration read in 198.760708ms |
| 49 | + gateway-1 | - Those servers are enabled: duckduckgo |
| 50 | + gateway-1 | - Listing MCP tools... |
| 51 | + ... |
| 52 | + ... |
| 53 | + gateway-1 | - Using images: |
| 54 | + gateway-1 | - mcp/duckduckgo@sha256:68eb20db6109f5c312a695fc5ec3386ad15d93ffb765a0b4eb1baf4328dec14f |
| 55 | + gateway-1 | > Images pulled in 37.201917ms |
| 56 | + gateway-1 | - Verifying images [mcp/duckduckgo] |
| 57 | + gateway-1 | > Images verified in 887.355875ms |
| 58 | + gateway-1 | > Initialized in 1.640829209s |
| 59 | + gateway-1 | > Start streaming server on port 8811 |
| 60 | + ``` |
| 61 | + |
| 62 | + That's it! The MCP Gateway is up and running! |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | +## Using the MCP Inspector |
| 67 | + |
| 68 | +The [MCP Inspector](https://github.com/modelcontextprotocol/inspector) is a great tool to directly interact with MCP servers, including the MCP Gateway. |
| 69 | + |
| 70 | +1. Start the MCP Inspector by using the following `npx` command: |
| 71 | + |
| 72 | + ```bash terminal-id=inspector |
| 73 | + npx --yes @modelcontextprotocol/inspector |
| 74 | + ``` |
| 75 | + |
| 76 | +2. Once it finishes, open the MCP Inspector running at :tabLink[http://localhost:6274]{href="http://localhost:6274" title="MCP Inspector"}. |
| 77 | + |
| 78 | +3. Configure the MCP Inspector to connect to a MCP server with the following configuration: |
| 79 | + |
| 80 | + - **Transport Type:** Streamable HTTP (you configured this in the Compose file) |
| 81 | + - **URL:** http://localhost:8811 |
| 82 | + |
| 83 | + Click **Connect** when you're done! |
| 84 | + |
| 85 | +4. Select the **Tools** tab and then click the **List Tools** button. |
| 86 | + |
| 87 | + You should see both the `fetch_content` and `search` tools appear. |
| 88 | + |
| 89 | +5. Select the **search** tool by clicking on it. |
| 90 | + |
| 91 | + This will open a form to fill out the required parameters. |
| 92 | + |
| 93 | +6. In the _query_ field, type in "Docker MCP Gateway". |
| 94 | + |
| 95 | +7. Click the **Run Tool** button. |
| 96 | + |
| 97 | + After a brief time, you should see your search results! |
| 98 | + |
| 99 | +While running the `search` tool, the Docker MCP Gateway started a DuckDuckGo container, delegated the running of the tool to it, got the results, stopped the container, and sent the results back to the inspector. |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | +## Next steps |
| 104 | + |
| 105 | +While this was a simple MCP server, not all are as straight forward. Many require some sort of authentication or configuration. |
| 106 | + |
| 107 | +In the next step, you'll add the GitHub MCP server to explore this. |
0 commit comments