Added metadata cli tests, renaming
This commit is contained in:
parent
b9963014a0
commit
809436d65c
3 changed files with 2907 additions and 138 deletions
|
|
@ -14,11 +14,11 @@ type JsonValue =
|
|||
// List available prompts
|
||||
export async function listPrompts(
|
||||
client: Client,
|
||||
metaData?: Record<string, string>,
|
||||
metadata?: Record<string, string>,
|
||||
): Promise<McpResponse> {
|
||||
try {
|
||||
const params =
|
||||
metaData && Object.keys(metaData).length > 0 ? { _meta: metaData } : {};
|
||||
metadata && Object.keys(metadata).length > 0 ? { _meta: metadata } : {};
|
||||
const response = await client.listPrompts(params);
|
||||
return response;
|
||||
} catch (error) {
|
||||
|
|
@ -33,7 +33,7 @@ export async function getPrompt(
|
|||
client: Client,
|
||||
name: string,
|
||||
args?: Record<string, JsonValue>,
|
||||
metaData?: Record<string, string>,
|
||||
metadata?: Record<string, string>,
|
||||
): Promise<McpResponse> {
|
||||
try {
|
||||
// Convert all arguments to strings for prompt arguments
|
||||
|
|
@ -55,8 +55,8 @@ export async function getPrompt(
|
|||
arguments: stringArgs,
|
||||
};
|
||||
|
||||
if (metaData && Object.keys(metaData).length > 0) {
|
||||
params._meta = metaData;
|
||||
if (metadata && Object.keys(metadata).length > 0) {
|
||||
params._meta = metadata;
|
||||
}
|
||||
|
||||
const response = await client.getPrompt(params);
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ import { McpResponse } from "./types.js";
|
|||
// List available resources
|
||||
export async function listResources(
|
||||
client: Client,
|
||||
metaData?: Record<string, string>,
|
||||
metadata?: Record<string, string>,
|
||||
): Promise<McpResponse> {
|
||||
try {
|
||||
const params =
|
||||
metaData && Object.keys(metaData).length > 0 ? { _meta: metaData } : {};
|
||||
metadata && Object.keys(metadata).length > 0 ? { _meta: metadata } : {};
|
||||
const response = await client.listResources(params);
|
||||
return response;
|
||||
} catch (error) {
|
||||
|
|
@ -22,12 +22,12 @@ export async function listResources(
|
|||
export async function readResource(
|
||||
client: Client,
|
||||
uri: string,
|
||||
metaData?: Record<string, string>,
|
||||
metadata?: Record<string, string>,
|
||||
): Promise<McpResponse> {
|
||||
try {
|
||||
const params: any = { uri };
|
||||
if (metaData && Object.keys(metaData).length > 0) {
|
||||
params._meta = metaData;
|
||||
if (metadata && Object.keys(metadata).length > 0) {
|
||||
params._meta = metadata;
|
||||
}
|
||||
const response = await client.readResource(params);
|
||||
return response;
|
||||
|
|
@ -41,11 +41,11 @@ export async function readResource(
|
|||
// List resource templates
|
||||
export async function listResourceTemplates(
|
||||
client: Client,
|
||||
metaData?: Record<string, string>,
|
||||
metadata?: Record<string, string>,
|
||||
): Promise<McpResponse> {
|
||||
try {
|
||||
const params =
|
||||
metaData && Object.keys(metaData).length > 0 ? { _meta: metaData } : {};
|
||||
metadata && Object.keys(metadata).length > 0 ? { _meta: metadata } : {};
|
||||
const response = await client.listResourceTemplates(params);
|
||||
return response;
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -21,11 +21,11 @@ type JsonSchemaType = {
|
|||
|
||||
export async function listTools(
|
||||
client: Client,
|
||||
metaData?: Record<string, string>,
|
||||
metadata?: Record<string, string>,
|
||||
): Promise<McpResponse> {
|
||||
try {
|
||||
const params =
|
||||
metaData && Object.keys(metaData).length > 0 ? { _meta: metaData } : {};
|
||||
metadata && Object.keys(metadata).length > 0 ? { _meta: metadata } : {};
|
||||
const response = await client.listTools(params);
|
||||
return response;
|
||||
} catch (error) {
|
||||
|
|
@ -87,11 +87,11 @@ export async function callTool(
|
|||
client: Client,
|
||||
name: string,
|
||||
args: Record<string, JsonValue>,
|
||||
generalMetaData?: Record<string, string>,
|
||||
toolSpecificMetaData?: Record<string, string>,
|
||||
generalMetadata?: Record<string, string>,
|
||||
toolSpecificMetadata?: Record<string, string>,
|
||||
): Promise<McpResponse> {
|
||||
try {
|
||||
const toolsResponse = await listTools(client, generalMetaData);
|
||||
const toolsResponse = await listTools(client, generalMetadata);
|
||||
const tools = toolsResponse.tools as Tool[];
|
||||
const tool = tools.find((t) => t.name === name);
|
||||
|
||||
|
|
@ -116,10 +116,10 @@ export async function callTool(
|
|||
// Merge general metadata with tool-specific metadata
|
||||
// Tool-specific metadata takes precedence over general metadata
|
||||
let mergedMeta: Record<string, string> | undefined;
|
||||
if (generalMetaData || toolSpecificMetaData) {
|
||||
if (generalMetadata || toolSpecificMetadata) {
|
||||
mergedMeta = {
|
||||
...(generalMetaData || {}),
|
||||
...(toolSpecificMetaData || {}),
|
||||
...(generalMetadata || {}),
|
||||
...(toolSpecificMetadata || {}),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue