-
-
Notifications
You must be signed in to change notification settings - Fork 8
Support MCP (Model Context Protocol). #177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Support validation feedback and model specification for MCP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for the Model Context Protocol (MCP) and enhances LLM function-calling capabilities in the @samchon/openapi package by introducing new namespaces, interfaces, and updated schema conversion logic.
- Added the McpLlm namespace and new interfaces to handle MCP-based tools and functions.
- Improved OpenAPI V3.1 schema conversion to correctly resolve references.
- Included new test cases for validating MCP application behavior and schema references.
Reviewed Changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
test/src/features/mcp/validate_mcp_application.ts | Added tests for validating MCP applications with various models. |
test/src/features/mcp/test_mcp_schema_ref.ts | Introduced schema reference testing to ensure proper filtering and resolution. |
src/structures/IMcpTool.ts | Defined the IMcpTool interface for MCP tools with associated schema definitions. |
src/structures/IMcpLlmFunction.ts | Added MCP LLM function interface with validation features. |
src/structures/IMcpLlmApplication.ts | Defined the MCP LLM application interface for aggregating functions and errors. |
src/ILlmFunction.ts | Updated ILlmFunction interface to include separated parameters. |
src/index.ts | Exported new MCP and related interfaces for external usage. |
src/converters/OpenApiV3_1Emender.ts | Revised schema conversion functions to standardize $ref resolution. |
src/McpLlm.ts | Implemented the MCP to LLM application conversion with error handling. |
src/HttpLlm.ts | Updated documentation to reflect the new MCP-based composition approach. |
Files not reviewed (1)
- package.json: Language not supported
Comments suppressed due to low confidence (2)
src/structures/IMcpTool.ts:47
- The term 'restict' appears to be a spelling error; please change it to 'restrict'.
* As MCP (Model Context Protocol) does not restict the JSON schema specification, `@samchon/openapi` has defined it to be universal
src/structures/IMcpLlmApplication.ts:22
- There is a spelling mistake in 'functi0on'; it should be 'function'.
* each function has its own {@link IMcpLlmFunction.validate} functi0on for correcting AI agent's mistakes, and this is the reason why
src/McpLlm.ts
Outdated
[key, (props.options as any)?.[key] ?? value] as const, | ||
), | ||
), | ||
maxLength: props.options?.maxLength ?? null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default for maxLength is set to null, but according to the IOptions type it should be a number; consider using a numeric default such as 64.
maxLength: props.options?.maxLength ?? null, | |
maxLength: props.options?.maxLength ?? 64, |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for MCP (Model Context Protocol) integration and enhances LLM function-calling capabilities in the @samchon/openapi package. It introduces new MCP namespaces and interfaces, updates OpenAPI V3.1 schema conversion utilities, and supplements the package with additional test cases to validate the new MCP functionalities.
Reviewed Changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
test/src/features/mcp/validate_mcp_application.ts | Adds tests to validate MCP applications for various models. |
test/src/features/mcp/test_mcp_schema_ref.ts | Introduces a test case to verify schema reference filtering in MCP. |
src/structures/IMcpTool.ts | Defines the interface for MCP tools. |
src/structures/IMcpLlmFunction.ts | Adds type definitions for MCP LLM functions. |
src/structures/IMcpLlmApplication.ts | Defines the application interface for MCP-based LLM functions. |
src/structures/ILlmFunction.ts | Enhances ILlmFunction interface with separated parameter support. |
src/index.ts | Exports the new MCP namespaces and structures. |
src/converters/OpenApiV3_1Emender.ts | Updates schema conversion functions for OpenAPI components and refs. |
src/McpLlm.ts | Implements MCP-to-LLM application conversion with validation support. |
src/HttpLlm.ts | Adjusts HTTP LLM application composition by enforcing a default maxLength. |
Files not reviewed (1)
- package.json: Language not supported
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Support validation feedback and LLM model specification for MCP.
This pull request introduces a significant update to the
@samchon/openapi
package, focusing on adding support for MCP (Model Context Protocol) integration and enhancing the LLM (Large Language Model) function-calling capabilities. Key changes include the addition of theMcpLlm
namespace, new structures for MCP-based function handling, and updates to OpenAPI V3.1 schema conversion utilities. These changes aim to improve schema validation, function composition, and error handling for LLM applications.MCP Integration and LLM Enhancements:
McpLlm
namespace insrc/McpLlm.ts
, which includes a newapplication
function for converting MCP documents into LLM function-calling applications. This includes support for schema validation, error handling, and context reduction strategies.IMcpLlmApplication
,IMcpLlmFunction
, andIMcpTool
, which define the structure and metadata for MCP-based LLM functions and tools. These interfaces support validation and error reporting during function composition. [1] [2] [3]src/index.ts
to export the newly added MCP-related namespaces and structures.OpenAPI V3.1 Schema Conversion Improvements:
convertComponents
andconvertSchema
functions inOpenApiV3_1Emender
to enable external usage for schema conversion. [1] [2]$ref
and$recursiveRef
attributes more robustly, ensuring proper resolution of references in OpenAPI schemas. [1] [2]Documentation and Test Additions:
test_mcp_schema_ref
, to validate MCP schema references and ensure compatibility with LLM function calling.Miscellaneous Updates:
package.json
version from4.1.0
to4.2.0
to reflect the new features and improvements.HttpLlm
namespace to align with the new MCP-based approach.These updates collectively enhance the package's ability to handle MCP documents and improve the reliability of LLM function-calling workflows.