@tiangong-lca/mcp-server 0.0.15 → 0.0.16
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.
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createClient } from '@supabase/supabase-js';
|
|
2
2
|
import { Redis } from '@upstash/redis';
|
|
3
3
|
import { authenticateCognitoToken } from './cognito_auth.js';
|
|
4
|
-
import { redis_token, redis_url,
|
|
4
|
+
import { redis_token, redis_url, supabase_base_url, supabase_publishable_key } from './config.js';
|
|
5
5
|
import decodeApiKey from './decode_api_key.js';
|
|
6
|
-
const supabase = createClient(supabase_base_url,
|
|
6
|
+
const supabase = createClient(supabase_base_url, supabase_publishable_key);
|
|
7
7
|
const redis = new Redis({
|
|
8
8
|
url: redis_url,
|
|
9
9
|
token: redis_token,
|
|
@@ -6,8 +6,7 @@ export const COGNITO_ISSUER = `https://cognito-idp.${COGNITO_REGION}.amazonaws.c
|
|
|
6
6
|
export const COGNITO_JWKS_URL = `${COGNITO_ISSUER}/.well-known/jwks.json`;
|
|
7
7
|
export const COGNITO_BASE_URL = 'https://us-east-1snsyimond.auth.us-east-1.amazoncognito.com';
|
|
8
8
|
export const supabase_base_url = process.env.SUPABASE_BASE_URL ?? 'https://qgzvkongdjqiiamzbbts.supabase.co';
|
|
9
|
-
export const
|
|
10
|
-
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InFnenZrb25nZGpxaWlhbXpiYnRzIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDAzNjUyMzQsImV4cCI6MjA1NTk0MTIzNH0.PsZIcjAqexpqIg-91twpKjALyw9big6Bn4WRLLoCzTo';
|
|
9
|
+
export const supabase_publishable_key = process.env.SUPABASE_PUBLISHABLE_KEY ?? 'sb_publishable_EFWH4E61tpAtf82WQ37xTA_Fxa5OPyg';
|
|
11
10
|
export const x_region = process.env.X_REGION ?? 'us-east-1';
|
|
12
11
|
export const redis_url = process.env.UPSTASH_REDIS_URL ?? '';
|
|
13
12
|
export const redis_token = process.env.UPSTASH_REDIS_TOKEN ?? '';
|
|
@@ -2,18 +2,16 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
2
2
|
import { regBomCalculationTool } from '../tools/bom_calculation.js';
|
|
3
3
|
import { regFlowSearchTool } from '../tools/flow_hybrid_search.js';
|
|
4
4
|
import { regProcessSearchTool } from '../tools/process_hybrid_search.js';
|
|
5
|
-
|
|
6
|
-
export function initializeServer(bearerKey, xApiKey) {
|
|
5
|
+
export function initializeServer(bearerKey) {
|
|
7
6
|
const server = new McpServer({
|
|
8
7
|
name: 'TianGong-LCA-MCP-Server',
|
|
9
8
|
version: '1.0.0',
|
|
10
9
|
});
|
|
11
|
-
regFlowSearchTool(server, bearerKey
|
|
12
|
-
regProcessSearchTool(server, bearerKey
|
|
10
|
+
regFlowSearchTool(server, bearerKey);
|
|
11
|
+
regProcessSearchTool(server, bearerKey);
|
|
13
12
|
regBomCalculationTool(server);
|
|
14
13
|
return server;
|
|
15
14
|
}
|
|
16
15
|
export function getServer(bearerKey) {
|
|
17
|
-
|
|
18
|
-
return initializeServer(tokenType !== 'supabase' ? undefined : bearerKey, tokenType !== 'supabase' ? bearerKey : undefined);
|
|
16
|
+
return initializeServer(bearerKey);
|
|
19
17
|
}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import cleanObject from '../_shared/clean_object.js';
|
|
3
|
-
import {
|
|
3
|
+
import { supabase_base_url, x_region } from '../_shared/config.js';
|
|
4
4
|
const input_schema = {
|
|
5
5
|
query: z.string().min(1).describe('Queries from user'),
|
|
6
6
|
};
|
|
7
|
-
async function searchFlows({ query }, bearerKey
|
|
7
|
+
async function searchFlows({ query }, bearerKey) {
|
|
8
8
|
const url = `${supabase_base_url}/functions/v1/flow_hybrid_search`;
|
|
9
9
|
try {
|
|
10
10
|
const response = await fetch(url, {
|
|
11
11
|
method: 'POST',
|
|
12
12
|
headers: {
|
|
13
13
|
'Content-Type': 'application/json',
|
|
14
|
-
Authorization: `Bearer ${bearerKey
|
|
15
|
-
...(xApiKey && { 'x-api-key': xApiKey }),
|
|
14
|
+
Authorization: `Bearer ${bearerKey}`,
|
|
16
15
|
'x-region': x_region,
|
|
17
16
|
},
|
|
18
17
|
body: JSON.stringify(cleanObject({
|
|
@@ -30,11 +29,11 @@ async function searchFlows({ query }, bearerKey, xApiKey) {
|
|
|
30
29
|
throw error;
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
|
-
export function regFlowSearchTool(server, bearerKey
|
|
32
|
+
export function regFlowSearchTool(server, bearerKey) {
|
|
34
33
|
server.tool('Search_flows_Tool', 'Search LCA flows data.', input_schema, async ({ query }) => {
|
|
35
34
|
const result = await searchFlows({
|
|
36
35
|
query,
|
|
37
|
-
}, bearerKey
|
|
36
|
+
}, bearerKey);
|
|
38
37
|
return {
|
|
39
38
|
content: [
|
|
40
39
|
{
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import cleanObject from '../_shared/clean_object.js';
|
|
3
|
-
import {
|
|
3
|
+
import { supabase_base_url, x_region } from '../_shared/config.js';
|
|
4
4
|
const input_schema = {
|
|
5
5
|
query: z.string().min(1).describe('Queries from user'),
|
|
6
6
|
};
|
|
7
|
-
async function searchProcesses({ query }, bearerKey
|
|
7
|
+
async function searchProcesses({ query }, bearerKey) {
|
|
8
8
|
const url = `${supabase_base_url}/functions/v1/process_hybrid_search`;
|
|
9
9
|
try {
|
|
10
10
|
const response = await fetch(url, {
|
|
11
11
|
method: 'POST',
|
|
12
12
|
headers: {
|
|
13
13
|
'Content-Type': 'application/json',
|
|
14
|
-
Authorization: `Bearer ${bearerKey
|
|
15
|
-
...(xApiKey && { 'x-api-key': xApiKey }),
|
|
14
|
+
Authorization: `Bearer ${bearerKey}`,
|
|
16
15
|
'x-region': x_region,
|
|
17
16
|
},
|
|
18
17
|
body: JSON.stringify(cleanObject({
|
|
@@ -30,11 +29,11 @@ async function searchProcesses({ query }, bearerKey, xApiKey) {
|
|
|
30
29
|
throw error;
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
|
-
export function regProcessSearchTool(server, bearerKey
|
|
32
|
+
export function regProcessSearchTool(server, bearerKey) {
|
|
34
33
|
server.tool('Search_processes_Tool', 'Search LCA processes data.', input_schema, async ({ query }) => {
|
|
35
34
|
const result = await searchProcesses({
|
|
36
35
|
query,
|
|
37
|
-
}, bearerKey
|
|
36
|
+
}, bearerKey);
|
|
38
37
|
return {
|
|
39
38
|
content: [
|
|
40
39
|
{
|