Goose allows you to extend its functionality by creating your own custom extensions, which are built as MCP servers. These extensions are compatible with Goose because it adheres to the [Model Context Protocol (MCP)][mcp-docs]. MCP is an open protocol that standardizes how applications provide context to LLMs. It enables a consistent way to connect LLMs to various data sources and tools, making it ideal for extending functionality in a structured and interoperable way.
In this guide, we build an MCP server using the [Python SDK for MCP][mcp-python]. We’ll demonstrate how to create an MCP server that reads Wikipedia articles and converts them to Markdown, integrate it as an extension in Goose. You can follow a similar process to develop your own custom extensions for Goose.
You can checkout other examples in this [MCP servers repository][mcp-servers]. MCP SDKs are also available in [Typescript][mcp-typescript] and [Kotlin][mcp-kotlin].
:::info
Goose currently supports Tools and Resources for [MCP Server features](https://spec.modelcontextprotocol.io/specification/2024-11-05/server/).
We will be adding support for MCP Prompts soon.
:::
---
## Step 1: Initialize Your Project
The first step is to create a new project using [uv][uv-docs]. We will name our project `mcp-wiki`.
Run the following commands in your terminal to set up a basic structure for your MCP server:
In this step, we’ll implement the core functionality of the MCP server. Here is a breakdown of the key components:
1.**`server.py`**: This file holds the main MCP server code. In this example, we define a single tool to read Wikipedia articles. You can add your own custom tools, resources, and prompts here.
2.**`__init__.py`**: This is the primary CLI entry point for your MCP server.
3.**`__main__.py`**: This file allows your MCP server to be executed as a Python module.
Below is the example implementation for the Wikipedia MCP server:
"""MCP Wiki: Read Wikipedia articles and convert them to Markdown."""
parser=argparse.ArgumentParser(
description="Gives you the ability to read Wikipedia articles and convert them to Markdown."
)
parser.parse_args()
mcp.run()
if__name__=="__main__":
main()
```
### `__main__.py`
```python
frommcp_wikiimportmain
main()
```
---
## Step 3: Define Project Configuration
Configure your project using `pyproject.toml`.This configuration defines the CLI script so that the mcp-wiki command is available as a binary. Below is an example configuration:
```toml
[project]
name="mcp-wiki"
version="0.1.0"
description="MCP Server for Wikipedia"
readme="README.md"
requires-python=">=3.13"
dependencies=[
"beautifulsoup4>=4.12.3",
"html2text>=2024.2.26",
"mcp[cli]>=1.2.0",
"requests>=2.32.3",
]
[project.scripts]
mcp-wiki="mcp_wiki:main"
[build-system]
requires=["hatchling"]
build-backend="hatchling.build"
```
---
## Step 4: Test Your MCP Server
### Using MCP Inspector
1. Setup the project environment:
```bash
uv sync
```
2. Activate your virtual environment:
```bash
source .venv/bin/activate
```
3. Run your server in development mode:
```bash
mcp dev src/mcp_wiki/server.py
```
4. Go to `http://localhost:5173` in your browser to open the MCP Inspector UI.
5. In the UI, you can click "Connect" to initialize your MCP server. Then click on "Tools" tab > "List Tools" and you should see the `read_wikipedia_article` tool.
Then you can try to call the `read_wikipedia_article` tool with URL set to "https://en.wikipedia.org/wiki/Bangladesh" and click "Run Tool".
uv run /Users/smohammed/Development/mcp/mcp-wiki/.venv/bin/mcp-wiki
```
For the purposes on this guide, we'll run the local version. Alternatively, you can publish your package to PyPI.Once published, the server can be run directly using `uvx`. For example: