Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ After installation, you can run it as a script using:
python -m coin_api_mcp
```

### Direct Installation
You can also download the package and run it directly as a script with your default Python interpreter with the following command:
```bash
python server.py --api-key=<your-api-key>
```


## Configuration
Expand All @@ -71,7 +76,18 @@ export COINMARKETCAP_API_KEY=your_api_key_here
python -m coin_api_mcp --api-key=your_api_key_here
```

### Configure for Claude Desktop if you downloaded the whole repository

Add to your Claude settings:

```json
"mcpServers": {
"coin_api": {
"command": "python",
"args": ["/path/to/coin_api_mcp/server.py", "--api-key", "your_api_key_here"]
}
}
```
### Configure for Claude.app

Add to your Claude settings:
Expand Down
28 changes: 4 additions & 24 deletions src/coin_api_mcp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,11 @@
from . import server
import asyncio

def main():

"""MCP coin-api Server - A CoinMarketCap API wrapper for MCP."""
import argparse
import asyncio
import os

parser = argparse.ArgumentParser(
description="give a model the ability to get coin/crypto data"
)
parser.add_argument(
"--api-key",
type=str,
help="CoinMarketCap API key (can also be set via COINMARKETCAP_API_KEY environment variable)",
)

args = parser.parse_args()

# Check for API key in args first, then environment
api_key = args.api_key or os.getenv("COINMARKETCAP_API_KEY")
if not api_key:
parser.error("CoinMarketCap API key must be provided either via --api-key or COINMARKETCAP_API_KEY environment variable")

def main():
"""Main entry point for the package."""
asyncio.run(server.main(api_key))
asyncio.run(server.main())


# Optionally expose other important items at package level
__all__ = ['main', 'server']
__all__ = ["main", "server"]
5 changes: 3 additions & 2 deletions src/coin_api_mcp/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from coin_api_mcp import main
from coin_api_mcp.server import main

main()
if __name__ == "__main__":
main()
9 changes: 1 addition & 8 deletions src/coin_api_mcp/server.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from typing import Any
import asyncio
import httpx
from mcp.server.models import InitializationOptions
import mcp.types as types
Expand Down Expand Up @@ -375,10 +374,4 @@ async def main(api_key: str):
experimental_capabilities={},
),
),
)

# This is needed if you'd like to connect to a custom client
if __name__ == "__main__":
#get api key from coinmarketcap
api_key = "xxxxxxx"
asyncio.run(main(api_key))
)