MCP/Constants.pm

filter: Statementstmt 100% 11 / 11 Branchbran n/a Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 88.2% 15 / 17 CC 2 SCAR 4.2
CC
2
Cov
92%
BEGIN
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.5
« MCP/Server/Subscription.pm ↑ Summary MCP/Server/Transport.pm »
1 package MCP::Constants;
2 10 ▶use Mojo::Base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 10 ▶use constant {
Subroutine BEGIN: called CC=2 SCAR=7.1
5 HEADER_MISMATCH => -32020,
6 INSUFFICIENT_SCOPE => -32003,
7 INTERNAL_ERROR => -32603,
8 INVALID_PARAMS => -32602,
9 INVALID_REQUEST => -32600,
10 META_CLIENT_CAPABILITIES => 'io.modelcontextprotocol/clientCapabilities',
11 META_CLIENT_INFO => 'io.modelcontextprotocol/clientInfo',
12 META_LOG_LEVEL => 'io.modelcontextprotocol/logLevel',
13 META_PROTOCOL_VERSION => 'io.modelcontextprotocol/protocolVersion',
14 META_SERVER_INFO => 'io.modelcontextprotocol/serverInfo',
15 META_SUBSCRIPTION_ID => 'io.modelcontextprotocol/subscriptionId',
16 METHOD_NOT_FOUND => -32601,
17 MISSING_CLIENT_CAPABILITY => -32021,
18 PARSE_ERROR => -32700,
19 10 ▶ PROTOCOL_VERSION => $ENV{MOJO_MCP_VERSION} || '2026-07-28',
Condition50%1/2
$ENV{'MOJO_MCP_VERSION'} || '2026-07-28'
l!l
010
MC/DC0%0/1
$ENV{'MOJO_MCP_VERSION'} || '2026-07-28'
$ENV{'MOJO_MCP_VERSION'}
Truth table50%1/2
A
A= $ENV{'MOJO_MCP_VERSION'}
Aresult
11
00
20 UNSUPPORTED_PROTOCOL_VERSION => -32022
21 10 };
22  
23 10 ▶use constant SUPPORTED_VERSIONS => [PROTOCOL_VERSION];
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 10 our @EXPORT_OK = (
26 qw(HEADER_MISMATCH INSUFFICIENT_SCOPE INTERNAL_ERROR INVALID_PARAMS INVALID_REQUEST META_CLIENT_CAPABILITIES),
27 qw(META_CLIENT_INFO META_LOG_LEVEL META_PROTOCOL_VERSION META_SERVER_INFO META_SUBSCRIPTION_ID),
28 qw(METHOD_NOT_FOUND MISSING_CLIENT_CAPABILITY PARSE_ERROR PROTOCOL_VERSION SUPPORTED_VERSIONS),
29 qw(UNSUPPORTED_PROTOCOL_VERSION)
30 );
31  
32 10 1;
33  
34 =encoding utf8
35  
36 =head1 NAME
37  
38 MCP::Constants - Constants for MCP (Model Context Protocol)
39  
40 =head1 SYNOPSIS
41  
42 use MCP::Constants qw(PROTOCOL_VERSION);
43  
44 =head1 DESCRIPTION
45  
46 L<MCP::Constants> provides constants used in MCP (Model Context Protocol).
47  
48 =head1 CONSTANTS
49  
50 L<MCP::Constants> exports the following constants.
51  
52 =head2 HEADER_MISMATCH
53  
54 The error code for a request whose routing headers disagree with its JSON-RPC body.
55  
56 =head2 INSUFFICIENT_SCOPE
57  
58 The error code for a request whose access token lacks a required OAuth scope. This is a local authorization policy
59 rather than a spec-defined code, and lives in the C<-32000> to C<-32019> range the specification grandfathers for
60 existing SDK use; C<-32020> to C<-32099> is reserved for the specification itself.
61  
62 =head2 INTERNAL_ERROR
63  
64 The error code for a prompt, resource, or tool that died, or returned a promise that was rejected.
65  
66 =head2 INVALID_PARAMS
67  
68 The error code for invalid parameters. Also used for prompts, resources, and tools that were not found.
69  
70 =head2 INVALID_REQUEST
71  
72 The error code for an invalid request.
73  
74 =head2 META_CLIENT_CAPABILITIES
75  
76 The C<_meta> key carrying the capabilities of the client making the request.
77  
78 =head2 META_CLIENT_INFO
79  
80 The C<_meta> key carrying the name and version of the client making the request.
81  
82 =head2 META_LOG_LEVEL
83  
84 The C<_meta> key carrying the minimum log level the client wants to receive for a request.
85  
86 =head2 META_PROTOCOL_VERSION
87  
88 The C<_meta> key carrying the protocol version a request is made with.
89  
90 =head2 META_SERVER_INFO
91  
92 The C<_meta> key carrying the name and version of the server in a result.
93  
94 =head2 META_SUBSCRIPTION_ID
95  
96 The C<_meta> key carrying the subscription a notification belongs to.
97  
98 =head2 METHOD_NOT_FOUND
99  
100 The error code for a method that was not found.
101  
102 =head2 MISSING_CLIENT_CAPABILITY
103  
104 The error code for a request that requires a client capability the client did not declare.
105  
106 =head2 PARSE_ERROR
107  
108 The error code for a parse error.
109  
110 =head2 PROTOCOL_VERSION
111  
112 The version of the Model Context Protocol being used.
113  
114 =head2 SUPPORTED_VERSIONS
115  
116 An array reference with every protocol version the server accepts, newest first.
117  
118 =head2 UNSUPPORTED_PROTOCOL_VERSION
119  
120 The error code for a request made with a protocol version the server does not support.
121  
122 =head1 SEE ALSO
123  
124 L<MCP>, L<https://mojolicious.org>, L<https://modelcontextprotocol.io>.
125  
126 =cut
« MCP/Server/Subscription.pm ↑ Summary MCP/Server/Transport.pm »