Documentation
¶
Overview ¶
Package protobufparser provides a parser for Protocol Buffers.
Index ¶
- func ParseProtoByReflection(ctx context.Context, target string) (*descriptorpb.FileDescriptorSet, error)
- func ParseProtoFromDefs(_ context.Context, protoDefinitions []*configv1.ProtoDefinition, ...) (*descriptorpb.FileDescriptorSet, error)
- type McpField
- type McpPrompt
- type McpResource
- type McpTool
- type ParsedMcpAnnotations
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseProtoByReflection ¶
func ParseProtoByReflection(ctx context.Context, target string) (*descriptorpb.FileDescriptorSet, error)
ParseProtoByReflection connects to a gRPC service that has server reflection enabled, discovers its entire set of protobuf definitions, including all dependencies, and returns them as a complete FileDescriptorSet.
ctx is the context for the reflection process, including timeouts. target is the address of the gRPC service to connect to.
func ParseProtoFromDefs ¶
func ParseProtoFromDefs( _ context.Context, protoDefinitions []*configv1.ProtoDefinition, protoCollections []*configv1.ProtoCollection, ) (*descriptorpb.FileDescriptorSet, error)
ParseProtoFromDefs parses a set of protobuf definitions from a slice of ProtoDefinition and a ProtoCollection. It writes the proto files to a temporary directory, invokes protoc to generate a FileDescriptorSet, and then returns the parsed FileDescriptorSet.
Types ¶
type McpField ¶
McpField represents a field within a protobuf message, including its name, description, type, and whether it is repeated.
func (*McpField) GetDescription ¶
GetDescription returns the description of the McpField.
type McpPrompt ¶
type McpPrompt struct {
Name string
Description string
Template string
ServiceName string
MethodName string
FullMethodName string
RequestType string
ResponseType string
}
McpPrompt represents the information extracted from a gRPC method that has been annotated as an MCP prompt.
type McpResource ¶
McpResource represents a protobuf message that has been annotated as an MCP resource.
type McpTool ¶
type McpTool struct {
Name string
Description string
ServiceName string
MethodName string
FullMethodName string // e.g., /package.ServiceName/MethodName
RequestType string // Fully qualified name
ResponseType string // Fully qualified name
RequestFields []McpField
ResponseFields []McpField
ReadOnlyHint bool
DestructiveHint bool
IdempotentHint bool
OpenWorldHint bool
}
McpTool represents the information extracted from a gRPC method that has been annotated as an MCP tool.
type ParsedMcpAnnotations ¶
type ParsedMcpAnnotations struct {
Tools []McpTool
Prompts []McpPrompt
Resources []McpResource
}
ParsedMcpAnnotations holds the structured data extracted from MCP (Model Context Protocol) annotations within a set of protobuf files.
func ExtractMcpDefinitions ¶
func ExtractMcpDefinitions(fds *descriptorpb.FileDescriptorSet) (*ParsedMcpAnnotations, error)
ExtractMcpDefinitions iterates through a FileDescriptorSet, parsing any MCP (Model Context Protocol) options found in service methods and messages. It extracts definitions for tools, prompts, and resources.
fds is the FileDescriptorSet to be parsed. It returns a ParsedMcpAnnotations struct containing the extracted information or an error if the parsing fails.