Skip to main content
Glama

Hashkey MCP Server

Official
by HashkeyHSK
utils.ts1.7 kB
import crypto from 'crypto'; // import { flaunchActionProvider } from '@hashkeychain/agentkit'; import type { Tool } from '@modelcontextprotocol/sdk/types.js'; import { z } from 'zod'; import { zodToJsonSchema, type JsonSchema7Type } from 'zod-to-json-schema'; import type { ToolHandler } from './tools/types.js'; type GenerateToolParams = { name: string; description: string; inputSchema: z.ZodSchema; toolHandler: ToolHandler; }; type RawSchemaType = JsonSchema7Type & { $schema?: string | undefined; $ref?: string | undefined; definitions?: | { [key: string]: JsonSchema7Type; } | undefined; }; function simplifySchema(schema: RawSchemaType): JsonSchema7Type { const result = { ...schema }; delete result.$schema; delete result.$ref; delete result.definitions; return result; } export function generateTool({ name, description, inputSchema: zodSchema, toolHandler, }: GenerateToolParams): { definition: Tool; handler: ToolHandler; } { const rawSchema = zodToJsonSchema(zodSchema); const inputSchema = simplifySchema(rawSchema) as Tool['inputSchema']; return { definition: { name, description, inputSchema, }, handler: toolHandler, }; } /** * Some AgentKit action providers throw if a key isn't set * This function returns a list of action providers that have required env vars */ export function getActionProvidersWithRequiredEnvVars() { if (process.env.PINATA_JWT) { // flaunchActionProvider 新版本才有 jwt 相关的东西 // return [flaunchActionProvider()]; return []; } return []; } export function generateSessionId(): string { return crypto.randomUUID(); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/HashkeyHSK/hsk-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server