diff --git a/cli/scripts/cli-metadata-tests.js b/cli/scripts/cli-metadata-tests.js index 881e1894..0bc664d2 100755 --- a/cli/scripts/cli-metadata-tests.js +++ b/cli/scripts/cli-metadata-tests.js @@ -300,8 +300,6 @@ async function runTests() { "tools/list", "--metadata", "client=test-client", - "version=1.0.0", - "environment=test", ); // Test 2: General metadata with resources/list @@ -314,8 +312,6 @@ async function runTests() { "resources/list", "--metadata", "client=test-client", - "version=1.0.0", - "environment=test", ); // Test 3: General metadata with prompts/list @@ -328,8 +324,6 @@ async function runTests() { "prompts/list", "--metadata", "client=test-client", - "version=1.0.0", - "environment=test", ); // Test 4: General metadata with resources/read @@ -344,8 +338,6 @@ async function runTests() { "test://static/resource/1", "--metadata", "client=test-client", - "version=1.0.0", - "environment=test", ); // Test 5: General metadata with prompts/get @@ -360,8 +352,6 @@ async function runTests() { "simple_prompt", "--metadata", "client=test-client", - "version=1.0.0", - "environment=test", ); console.log( @@ -381,9 +371,7 @@ async function runTests() { "--tool-arg", "message=hello world", "--tool-metadata", - "tool-client=test-tool-client", - "tool-version=2.0.0", - "tool-environment=test-tool", + "client=test-client", ); // Test 7: Tool-specific metadata with complex tool @@ -400,9 +388,7 @@ async function runTests() { "a=10", "b=20", "--tool-metadata", - "operation=addition", - "precision=integer", - "validation=strict", + "client=test-client", ); console.log( @@ -423,32 +409,14 @@ async function runTests() { "message=hello world", "--metadata", "client=general-client", - "version=1.0.0", - "environment=general", "--tool-metadata", - "client=tool-specific-client", - "tool-version=2.0.0", - "tool-environment=tool-specific", + "client=test-client", ); console.log( `\n${colors.YELLOW}=== Running Metadata Parsing Tests ===${colors.NC}`, ); - // Test 9: Metadata with string values - await runBasicTest( - "metadata_parsing_strings", - TEST_CMD, - ...TEST_ARGS, - "--cli", - "--method", - "tools/list", - "--metadata", - "string_value=hello world", - 'quoted_string="quoted value"', - 'empty_string=""', - ); - // Test 10: Metadata with numeric values (should be converted to strings) await runBasicTest( "metadata_parsing_numbers", @@ -463,20 +431,7 @@ async function runTests() { "negative_value=-10", ); - // Test 11: Metadata with boolean values (should be converted to strings) - await runBasicTest( - "metadata_parsing_booleans", - TEST_CMD, - ...TEST_ARGS, - "--cli", - "--method", - "tools/list", - "--metadata", - "true_value=true", - "false_value=false", - ); - - // Test 12: Metadata with JSON values (should be converted to strings) + // Test 11: Metadata with JSON values (should be converted to strings) await runBasicTest( "metadata_parsing_json", TEST_CMD, @@ -490,7 +445,7 @@ async function runTests() { 'json_string="\\"quoted\\""', ); - // Test 13: Metadata with special characters + // Test 12: Metadata with special characters await runBasicTest( "metadata_parsing_special_chars", TEST_CMD, @@ -508,7 +463,7 @@ async function runTests() { `\n${colors.YELLOW}=== Running Metadata Edge Cases ===${colors.NC}`, ); - // Test 14: Single metadata entry + // Test 13: Single metadata entry await runBasicTest( "metadata_single_entry", TEST_CMD, @@ -520,7 +475,7 @@ async function runTests() { "single_key=single_value", ); - // Test 15: Many metadata entries + // Test 14: Many metadata entries await runBasicTest( "metadata_many_entries", TEST_CMD, @@ -540,7 +495,7 @@ async function runTests() { `\n${colors.YELLOW}=== Running Metadata Error Cases ===${colors.NC}`, ); - // Test 16: Invalid metadata format (missing equals) + // Test 15: Invalid metadata format (missing equals) await runErrorTest( "metadata_error_invalid_format", TEST_CMD, @@ -552,7 +507,7 @@ async function runTests() { "invalid_format_no_equals", ); - // Test 17: Invalid tool-meta format (missing equals) + // Test 16: Invalid tool-meta format (missing equals) await runErrorTest( "metadata_error_invalid_tool_meta_format", TEST_CMD, @@ -568,11 +523,81 @@ async function runTests() { "invalid_format_no_equals", ); + console.log( + `\n${colors.YELLOW}=== Running Metadata Impact Tests ===${colors.NC}`, + ); + + // Test 17: Test tool-specific metadata vs general metadata precedence + await runBasicTest( + "metadata_precedence_tool_overrides_general", + TEST_CMD, + ...TEST_ARGS, + "--cli", + "--method", + "tools/call", + "--tool-name", + "echo", + "--tool-arg", + "message=precedence test", + "--metadata", + "client=general-client", + "--tool-metadata", + "client=tool-specific-client", + ); + + // Test 18: Test metadata with resources methods + await runBasicTest( + "metadata_resources_methods", + TEST_CMD, + ...TEST_ARGS, + "--cli", + "--method", + "resources/list", + "--metadata", + "resource_client=test-resource-client", + ); + + // Test 19: Test metadata with prompts methods + await runBasicTest( + "metadata_prompts_methods", + TEST_CMD, + ...TEST_ARGS, + "--cli", + "--method", + "prompts/get", + "--prompt-name", + "simple_prompt", + "--metadata", + "prompt_client=test-prompt-client", + ); + + console.log( + `\n${colors.YELLOW}=== Running Metadata Validation Tests ===${colors.NC}`, + ); + + // Test 20: Test metadata with special characters in keys + await runBasicTest( + "metadata_special_key_characters", + TEST_CMD, + ...TEST_ARGS, + "--cli", + "--method", + "tools/call", + "--tool-name", + "echo", + "--tool-arg", + "message=special keys test", + "--metadata", + "key-with-dashes=value1", + "key_with_underscores=value2", + "key.with.dots=value3", + ); + console.log( `\n${colors.YELLOW}=== Running Metadata Integration Tests ===${colors.NC}`, ); - // Test 18: Metadata with all MCP methods + // Test 21: Metadata with all MCP methods await runBasicTest( "metadata_integration_all_methods", TEST_CMD, @@ -585,7 +610,7 @@ async function runTests() { "test_phase=all_methods", ); - // Test 19: Complex metadata scenario + // Test 22: Complex metadata scenario await runBasicTest( "metadata_complex_scenario", TEST_CMD, @@ -608,6 +633,27 @@ async function runTests() { "priority=high", ); + // Test 23: Metadata parsing validation test + await runBasicTest( + "metadata_parsing_validation", + TEST_CMD, + ...TEST_ARGS, + "--cli", + "--method", + "tools/call", + "--tool-name", + "echo", + "--tool-arg", + "message=parsing validation test", + "--metadata", + "valid_key=valid_value", + "numeric_key=123", + "boolean_key=true", + 'json_key=\'{"test":"value"}\'', + "special_key=!@#$%^&*()", + "unicode_key=🚀🎉✨", + ); + // Print test summary console.log(`\n${colors.YELLOW}=== Test Summary ===${colors.NC}`); console.log(`${colors.GREEN}Passed: ${PASSED_TESTS}${colors.NC}`); diff --git a/cli/scripts/metadata-test-output/metadata_empty.log b/cli/scripts/metadata-test-output/metadata_empty.log deleted file mode 100644 index 476e5324..00000000 --- a/cli/scripts/metadata-test-output/metadata_empty.log +++ /dev/null @@ -1,3 +0,0 @@ -Invalid parameter format: . Use key=value format. - -Failed with exit code: 1 diff --git a/cli/scripts/metadata-test-output/metadata_parsing_booleans.log b/cli/scripts/metadata-test-output/metadata_parsing_booleans.log deleted file mode 100644 index 114d6da4..00000000 --- a/cli/scripts/metadata-test-output/metadata_parsing_booleans.log +++ /dev/null @@ -1,218 +0,0 @@ -{ - "tools": [ - { - "name": "echo", - "description": "Echoes back the input", - "inputSchema": { - "type": "object", - "properties": { - "message": { - "type": "string", - "description": "Message to echo" - } - }, - "required": [ - "message" - ], - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - } - }, - { - "name": "add", - "description": "Adds two numbers", - "inputSchema": { - "type": "object", - "properties": { - "a": { - "type": "number", - "description": "First number" - }, - "b": { - "type": "number", - "description": "Second number" - } - }, - "required": [ - "a", - "b" - ], - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - } - }, - { - "name": "longRunningOperation", - "description": "Demonstrates a long running operation with progress updates", - "inputSchema": { - "type": "object", - "properties": { - "duration": { - "type": "number", - "default": 10, - "description": "Duration of the operation in seconds" - }, - "steps": { - "type": "number", - "default": 5, - "description": "Number of steps in the operation" - } - }, - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - } - }, - { - "name": "printEnv", - "description": "Prints all environment variables, helpful for debugging MCP server configuration", - "inputSchema": { - "type": "object", - "properties": {}, - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - } - }, - { - "name": "sampleLLM", - "description": "Samples from an LLM using MCP's sampling feature", - "inputSchema": { - "type": "object", - "properties": { - "prompt": { - "type": "string", - "description": "The prompt to send to the LLM" - }, - "maxTokens": { - "type": "number", - "default": 100, - "description": "Maximum number of tokens to generate" - } - }, - "required": [ - "prompt" - ], - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - } - }, - { - "name": "getTinyImage", - "description": "Returns the MCP_TINY_IMAGE", - "inputSchema": { - "type": "object", - "properties": {}, - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - } - }, - { - "name": "annotatedMessage", - "description": "Demonstrates how annotations can be used to provide metadata about content", - "inputSchema": { - "type": "object", - "properties": { - "messageType": { - "type": "string", - "enum": [ - "error", - "success", - "debug" - ], - "description": "Type of message to demonstrate different annotation patterns" - }, - "includeImage": { - "type": "boolean", - "default": false, - "description": "Whether to include an example image" - } - }, - "required": [ - "messageType" - ], - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - } - }, - { - "name": "getResourceReference", - "description": "Returns a resource reference that can be used by MCP clients", - "inputSchema": { - "type": "object", - "properties": { - "resourceId": { - "type": "number", - "minimum": 1, - "maximum": 100, - "description": "ID of the resource to reference (1-100)" - } - }, - "required": [ - "resourceId" - ], - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - } - }, - { - "name": "getResourceLinks", - "description": "Returns multiple resource links that reference different types of resources", - "inputSchema": { - "type": "object", - "properties": { - "count": { - "type": "number", - "minimum": 1, - "maximum": 10, - "default": 3, - "description": "Number of resource links to return (1-10)" - } - }, - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - } - }, - { - "name": "structuredContent", - "description": "Returns structured content along with an output schema for client data validation", - "inputSchema": { - "type": "object", - "properties": { - "location": { - "type": "string", - "minLength": 1, - "description": "City name or zip code" - } - }, - "required": [ - "location" - ], - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - }, - "outputSchema": { - "type": "object", - "properties": { - "temperature": { - "type": "number", - "description": "Temperature in celsius" - }, - "conditions": { - "type": "string", - "description": "Weather conditions description" - }, - "humidity": { - "type": "number", - "description": "Humidity percentage" - } - }, - "required": [ - "temperature", - "conditions", - "humidity" - ], - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - } - } - ] -} \ No newline at end of file diff --git a/cli/scripts/metadata-test-output/metadata_parsing_strings.log b/cli/scripts/metadata-test-output/metadata_parsing_strings.log deleted file mode 100644 index 114d6da4..00000000 --- a/cli/scripts/metadata-test-output/metadata_parsing_strings.log +++ /dev/null @@ -1,218 +0,0 @@ -{ - "tools": [ - { - "name": "echo", - "description": "Echoes back the input", - "inputSchema": { - "type": "object", - "properties": { - "message": { - "type": "string", - "description": "Message to echo" - } - }, - "required": [ - "message" - ], - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - } - }, - { - "name": "add", - "description": "Adds two numbers", - "inputSchema": { - "type": "object", - "properties": { - "a": { - "type": "number", - "description": "First number" - }, - "b": { - "type": "number", - "description": "Second number" - } - }, - "required": [ - "a", - "b" - ], - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - } - }, - { - "name": "longRunningOperation", - "description": "Demonstrates a long running operation with progress updates", - "inputSchema": { - "type": "object", - "properties": { - "duration": { - "type": "number", - "default": 10, - "description": "Duration of the operation in seconds" - }, - "steps": { - "type": "number", - "default": 5, - "description": "Number of steps in the operation" - } - }, - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - } - }, - { - "name": "printEnv", - "description": "Prints all environment variables, helpful for debugging MCP server configuration", - "inputSchema": { - "type": "object", - "properties": {}, - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - } - }, - { - "name": "sampleLLM", - "description": "Samples from an LLM using MCP's sampling feature", - "inputSchema": { - "type": "object", - "properties": { - "prompt": { - "type": "string", - "description": "The prompt to send to the LLM" - }, - "maxTokens": { - "type": "number", - "default": 100, - "description": "Maximum number of tokens to generate" - } - }, - "required": [ - "prompt" - ], - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - } - }, - { - "name": "getTinyImage", - "description": "Returns the MCP_TINY_IMAGE", - "inputSchema": { - "type": "object", - "properties": {}, - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - } - }, - { - "name": "annotatedMessage", - "description": "Demonstrates how annotations can be used to provide metadata about content", - "inputSchema": { - "type": "object", - "properties": { - "messageType": { - "type": "string", - "enum": [ - "error", - "success", - "debug" - ], - "description": "Type of message to demonstrate different annotation patterns" - }, - "includeImage": { - "type": "boolean", - "default": false, - "description": "Whether to include an example image" - } - }, - "required": [ - "messageType" - ], - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - } - }, - { - "name": "getResourceReference", - "description": "Returns a resource reference that can be used by MCP clients", - "inputSchema": { - "type": "object", - "properties": { - "resourceId": { - "type": "number", - "minimum": 1, - "maximum": 100, - "description": "ID of the resource to reference (1-100)" - } - }, - "required": [ - "resourceId" - ], - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - } - }, - { - "name": "getResourceLinks", - "description": "Returns multiple resource links that reference different types of resources", - "inputSchema": { - "type": "object", - "properties": { - "count": { - "type": "number", - "minimum": 1, - "maximum": 10, - "default": 3, - "description": "Number of resource links to return (1-10)" - } - }, - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - } - }, - { - "name": "structuredContent", - "description": "Returns structured content along with an output schema for client data validation", - "inputSchema": { - "type": "object", - "properties": { - "location": { - "type": "string", - "minLength": 1, - "description": "City name or zip code" - } - }, - "required": [ - "location" - ], - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - }, - "outputSchema": { - "type": "object", - "properties": { - "temperature": { - "type": "number", - "description": "Temperature in celsius" - }, - "conditions": { - "type": "string", - "description": "Weather conditions description" - }, - "humidity": { - "type": "number", - "description": "Humidity percentage" - } - }, - "required": [ - "temperature", - "conditions", - "humidity" - ], - "additionalProperties": false, - "$schema": "http://json-schema.org/draft-07/schema#" - } - } - ] -} \ No newline at end of file diff --git a/cli/scripts/metadata-test-output/metadata_parsing_validation.log b/cli/scripts/metadata-test-output/metadata_parsing_validation.log new file mode 100644 index 00000000..b2dd290a --- /dev/null +++ b/cli/scripts/metadata-test-output/metadata_parsing_validation.log @@ -0,0 +1,8 @@ +{ + "content": [ + { + "type": "text", + "text": "Echo: parsing validation test" + } + ] +} \ No newline at end of file diff --git a/cli/scripts/metadata-test-output/metadata_precedence_tool_overrides_general.log b/cli/scripts/metadata-test-output/metadata_precedence_tool_overrides_general.log new file mode 100644 index 00000000..07c8f815 --- /dev/null +++ b/cli/scripts/metadata-test-output/metadata_precedence_tool_overrides_general.log @@ -0,0 +1,8 @@ +{ + "content": [ + { + "type": "text", + "text": "Echo: precedence test" + } + ] +} \ No newline at end of file diff --git a/cli/scripts/metadata-test-output/metadata_prompts_methods.log b/cli/scripts/metadata-test-output/metadata_prompts_methods.log new file mode 100644 index 00000000..bfeb0428 --- /dev/null +++ b/cli/scripts/metadata-test-output/metadata_prompts_methods.log @@ -0,0 +1,11 @@ +{ + "messages": [ + { + "role": "user", + "content": { + "type": "text", + "text": "This is a simple prompt without arguments." + } + } + ] +} \ No newline at end of file diff --git a/cli/scripts/metadata-test-output/metadata_resources_methods.log b/cli/scripts/metadata-test-output/metadata_resources_methods.log new file mode 100644 index 00000000..f0d23a35 --- /dev/null +++ b/cli/scripts/metadata-test-output/metadata_resources_methods.log @@ -0,0 +1,65 @@ +{ + "nextCursor": "MTA=", + "resources": [ + { + "name": "Resource 1", + "uri": "test://static/resource/1", + "mimeType": "text/plain", + "text": "Resource 1: This is a plaintext resource" + }, + { + "name": "Resource 2", + "uri": "test://static/resource/2", + "mimeType": "application/octet-stream", + "blob": "UmVzb3VyY2UgMjogVGhpcyBpcyBhIGJhc2U2NCBibG9i" + }, + { + "name": "Resource 3", + "uri": "test://static/resource/3", + "mimeType": "text/plain", + "text": "Resource 3: This is a plaintext resource" + }, + { + "name": "Resource 4", + "uri": "test://static/resource/4", + "mimeType": "application/octet-stream", + "blob": "UmVzb3VyY2UgNDogVGhpcyBpcyBhIGJhc2U2NCBibG9i" + }, + { + "name": "Resource 5", + "uri": "test://static/resource/5", + "mimeType": "text/plain", + "text": "Resource 5: This is a plaintext resource" + }, + { + "name": "Resource 6", + "uri": "test://static/resource/6", + "mimeType": "application/octet-stream", + "blob": "UmVzb3VyY2UgNjogVGhpcyBpcyBhIGJhc2U2NCBibG9i" + }, + { + "name": "Resource 7", + "uri": "test://static/resource/7", + "mimeType": "text/plain", + "text": "Resource 7: This is a plaintext resource" + }, + { + "name": "Resource 8", + "uri": "test://static/resource/8", + "mimeType": "application/octet-stream", + "blob": "UmVzb3VyY2UgODogVGhpcyBpcyBhIGJhc2U2NCBibG9i" + }, + { + "name": "Resource 9", + "uri": "test://static/resource/9", + "mimeType": "text/plain", + "text": "Resource 9: This is a plaintext resource" + }, + { + "name": "Resource 10", + "uri": "test://static/resource/10", + "mimeType": "application/octet-stream", + "blob": "UmVzb3VyY2UgMTA6IFRoaXMgaXMgYSBiYXNlNjQgYmxvYg==" + } + ] +} \ No newline at end of file diff --git a/cli/scripts/metadata-test-output/metadata_special_key_characters.log b/cli/scripts/metadata-test-output/metadata_special_key_characters.log new file mode 100644 index 00000000..54345ad3 --- /dev/null +++ b/cli/scripts/metadata-test-output/metadata_special_key_characters.log @@ -0,0 +1,8 @@ +{ + "content": [ + { + "type": "text", + "text": "Echo: special keys test" + } + ] +} \ No newline at end of file