mcp_coingecko_price_ts 1.0.0 → 1.0.1
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/README.md +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
+
import * as z from 'zod/v4';
|
|
4
|
+
const mcpServer = new McpServer({
|
|
5
|
+
name: 'tools-with-sample-server',
|
|
6
|
+
version: '1.0.0'
|
|
7
|
+
});
|
|
8
|
+
console.log('McpServer started');
|
|
9
|
+
mcpServer.registerTool('coingecko-price-ts', {
|
|
10
|
+
title: 'Get Cryptocurrency Price',
|
|
11
|
+
description: 'Get the current price of a cryptocurrency from CoinGecko.',
|
|
12
|
+
inputSchema: {
|
|
13
|
+
crypto_id: z.string(),
|
|
14
|
+
currency: z.string()
|
|
15
|
+
}
|
|
16
|
+
}, async ({ crypto_id, currency }) => {
|
|
17
|
+
const response = await fetch(`https://api.coingecko.com/api/v3/simple/price?ids=${crypto_id}&vs_currencies=${currency}`);
|
|
18
|
+
const data = await response.json();
|
|
19
|
+
const price = data[crypto_id][currency];
|
|
20
|
+
const output = `The current price of ${crypto_id} in ${currency} is ${price}`;
|
|
21
|
+
return {
|
|
22
|
+
content: [{ type: 'text', text: output }],
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
async function main() {
|
|
26
|
+
const transport = new StdioServerTransport();
|
|
27
|
+
await mcpServer.connect(transport);
|
|
28
|
+
console.log('MCP server is running...');
|
|
29
|
+
}
|
|
30
|
+
main().catch(error => {
|
|
31
|
+
console.error('Server error:', error);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC;IAC5B,IAAI,EAAE,0BAA0B;IAChC,OAAO,EAAE,OAAO;CACnB,CAAC,CAAC;AAEH,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;AAEjC,SAAS,CAAC,YAAY,CAClB,oBAAoB,EACpB;IACI,KAAK,EAAE,0BAA0B;IACjC,WAAW,EAAE,2DAA2D;IACxE,WAAW,EAAE;QACT,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;QACrB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;KACvB;CACJ,EACD,KAAK,EAAG,EAAC,SAAS,EAAE,QAAQ,EAAC,EAAG,EAAE;IAC9B,MAAM,QAAQ,GAAG,MAAM,KAAK,CACxB,qDAAqD,SAAS,kBAAkB,QAAQ,EAAE,CAC7F,CAAC;IACF,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACnC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,wBAAwB,SAAS,OAAO,QAAQ,OAAO,KAAK,EAAE,CAAC;IAC9E,OAAO;QACH,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE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