mcp-crypto-price 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/http.js CHANGED
@@ -4,9 +4,10 @@ import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/
4
4
  import { createServer } from './index.js';
5
5
  import { SERVER_CONFIG } from './config/index.js';
6
6
  const PORT = parseInt(process.env.PORT ?? '3000', 10);
7
- async function handleMcp(req, res) {
7
+ async function handleMcp(req, res, searchParams) {
8
+ const coincapApiKey = searchParams.get('coincapApiKey') ?? process.env.COINCAP_API_KEY;
8
9
  const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: undefined });
9
- const server = createServer({ config: { coincapApiKey: process.env.COINCAP_API_KEY } });
10
+ const server = createServer({ config: { coincapApiKey } });
10
11
  await server.connect(transport);
11
12
  if (req.method === 'POST') {
12
13
  const chunks = [];
@@ -88,21 +89,23 @@ const serverCard = {
88
89
  ],
89
90
  };
90
91
  const httpServer = http.createServer(async (req, res) => {
92
+ const parsed = new URL(req.url ?? '/', `http://localhost`);
93
+ const pathname = parsed.pathname;
91
94
  // MCP server card for discovery (required by Smithery)
92
- if (req.url === '/.well-known/mcp/server-card.json' && req.method === 'GET') {
95
+ if (pathname === '/.well-known/mcp/server-card.json' && req.method === 'GET') {
93
96
  res.writeHead(200, { 'Content-Type': 'application/json' });
94
97
  res.end(JSON.stringify(serverCard));
95
98
  return;
96
99
  }
97
100
  // Health check: GET / or GET /health
98
- if ((req.url === '/' || req.url === '/health') && req.method === 'GET') {
101
+ if ((pathname === '/' || pathname === '/health') && req.method === 'GET') {
99
102
  res.writeHead(200, { 'Content-Type': 'application/json' });
100
103
  res.end(JSON.stringify({ status: 'ok' }));
101
104
  return;
102
105
  }
103
- // MCP protocol: /mcp or / (POST/GET for SSE)
104
- if (req.url === '/mcp' || req.url === '/') {
105
- await handleMcp(req, res);
106
+ // MCP protocol: /mcp (POST/GET for SSE)
107
+ if (pathname === '/mcp') {
108
+ await handleMcp(req, res, parsed.searchParams);
106
109
  return;
107
110
  }
108
111
  res.writeHead(404);
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-crypto-price",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "A Model Context Protocol (MCP) server that provides real-time cryptocurrency data and analysis through CoinCap's API. Features include price tracking, market analysis, and historical trends.",
5
5
  "license": "MIT",
6
6
  "author": {
Binary file