@torqon/mcp 0.1.0

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.
Files changed (2) hide show
  1. package/dist/index.js +56 -0
  2. package/package.json +26 -0
package/dist/index.js ADDED
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env node
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
+ import { z } from 'zod';
5
+ const API_URL = process.env.TORQON_API_URL ?? 'https://torqon-production.up.railway.app';
6
+ const server = new McpServer({
7
+ name: 'torqon',
8
+ version: '0.1.0',
9
+ });
10
+ server.tool('optimize_context', 'Compresses a large raw prompt into a structured context package. Use when you have a long document or prompt that needs to be condensed.', { message: z.string().describe('The raw text to compress and optimize') }, async ({ message }) => {
11
+ const response = await fetch(`${API_URL}/chat`, {
12
+ method: 'POST',
13
+ headers: { 'Content-Type': 'application/json' },
14
+ body: JSON.stringify({
15
+ conversationId: `mcp-optimize-${Date.now()}`,
16
+ message,
17
+ }),
18
+ });
19
+ const data = await response.json();
20
+ return {
21
+ content: [{ type: 'text', text: data.response?.content ?? 'No response from Torqon' }],
22
+ };
23
+ });
24
+ server.tool('store_memory', 'Stores information into Torqon memory for a conversation. Use to feed facts or context that should be remembered.', {
25
+ conversationId: z.string().describe('The conversation or project identifier'),
26
+ message: z.string().describe('The information to store as memory'),
27
+ }, async ({ conversationId, message }) => {
28
+ await fetch(`${API_URL}/chat`, {
29
+ method: 'POST',
30
+ headers: { 'Content-Type': 'application/json' },
31
+ body: JSON.stringify({ conversationId, message, storeOnly: true }),
32
+ });
33
+ return {
34
+ content: [{ type: 'text', text: `Memory stored for conversation: ${conversationId}` }],
35
+ };
36
+ });
37
+ server.tool('retrieve_context', 'Retrieves relevant facts from Torqon memory for a given query. Use before generating a response to get stored context.', {
38
+ conversationId: z.string().describe('The conversation or project identifier'),
39
+ query: z.string().describe('The question or topic to retrieve context for'),
40
+ }, async ({ conversationId, query }) => {
41
+ const response = await fetch(`${API_URL}/chat`, {
42
+ method: 'POST',
43
+ headers: { 'Content-Type': 'application/json' },
44
+ body: JSON.stringify({ conversationId, message: query }),
45
+ });
46
+ const data = await response.json();
47
+ return {
48
+ content: [{ type: 'text', text: data.response?.content ?? 'No context found' }],
49
+ };
50
+ });
51
+ async function main() {
52
+ const transport = new StdioServerTransport();
53
+ await server.connect(transport);
54
+ console.error('Torqon MCP server running');
55
+ }
56
+ main().catch(console.error);
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@torqon/mcp",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "main": "dist/index.js",
6
+ "bin": {
7
+ "torqon-mcp": "dist/index.js"
8
+ },
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "scripts": {
13
+ "build": "tsc",
14
+ "start": "node dist/index.js",
15
+ "dev": "tsx src/index.ts"
16
+ },
17
+ "dependencies": {
18
+ "@modelcontextprotocol/sdk": "^1.0.0",
19
+ "zod": "^3.22.0"
20
+ },
21
+ "devDependencies": {
22
+ "@types/node": "^20.0.0",
23
+ "tsx": "^4.0.0",
24
+ "typescript": "^5.0.0"
25
+ }
26
+ }