Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75fe5a123c |
No files matched your search
@@ -67,10 +67,7 @@ impl LoggingEndpoint {
|
||||
.client
|
||||
.post(self.url(agent_slug))
|
||||
.header(reqwest::header::ACCEPT, "text/event-stream")
|
||||
.header(
|
||||
reqwest::header::AUTHORIZATION,
|
||||
format!("Bearer {api_key}"),
|
||||
);
|
||||
.header(reqwest::header::AUTHORIZATION, format!("Bearer {api_key}"));
|
||||
for (name, value) in headers {
|
||||
request = request.header(*name, *value);
|
||||
}
|
||||
@@ -111,11 +108,7 @@ impl LoggingEndpoint {
|
||||
}
|
||||
|
||||
/// One `logging/setLevel` request of the legacy era.
|
||||
async fn set_level(
|
||||
&self,
|
||||
session_id: &str,
|
||||
level: Value,
|
||||
) -> StreamReply {
|
||||
async fn set_level(&self, session_id: &str, level: Value) -> StreamReply {
|
||||
self.legacy_post(
|
||||
AGENT_SLUG,
|
||||
&self.api_key,
|
||||
@@ -574,7 +567,11 @@ async fn legacy_severity_filter_is_honoured() {
|
||||
json!({"jsonrpc": "2.0", "id": 72, "method": "prompts/get", "params": {}}),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(rejected.error().0, -32602, "a malformed request is a client error");
|
||||
assert_eq!(
|
||||
rejected.error().0,
|
||||
-32602,
|
||||
"a malformed request is a client error"
|
||||
);
|
||||
assert!(
|
||||
rejected.notifications.is_empty(),
|
||||
"a warning event is below the `error` level, got {:?}",
|
||||
@@ -737,7 +734,10 @@ async fn a_level_never_leaks_to_another_client() {
|
||||
|
||||
// Another initialized session of the same Agent never opted in.
|
||||
let other_session = endpoint.legacy_session(AGENT_SLUG, &endpoint.api_key).await;
|
||||
assert_ne!(session, other_session, "each initialize mints its own session");
|
||||
assert_ne!(
|
||||
session, other_session,
|
||||
"each initialize mints its own session"
|
||||
);
|
||||
let other = endpoint
|
||||
.legacy_post(
|
||||
AGENT_SLUG,
|
||||
@@ -766,7 +766,9 @@ async fn a_level_never_leaks_to_another_client() {
|
||||
|
||||
// ...and another Agent's session is unaffected by this Agent's level, both before and after it
|
||||
// sets its own.
|
||||
let other_agent_session = endpoint.legacy_session(OTHER_AGENT_SLUG, &endpoint.other_api_key).await;
|
||||
let other_agent_session = endpoint
|
||||
.legacy_session(OTHER_AGENT_SLUG, &endpoint.other_api_key)
|
||||
.await;
|
||||
let other_agent = endpoint
|
||||
.legacy_post(
|
||||
OTHER_AGENT_SLUG,
|
||||
|
||||
@@ -14,14 +14,14 @@ use crate::{
|
||||
method_name, params, request_id,
|
||||
},
|
||||
protocol::{
|
||||
CompletionCommand, CompletionOutcome, ContinuationSupport, DispatchDecision, EnvelopeKind,
|
||||
EVENT_LEVEL_APPLIED, INVALID_LEVEL, Kind, LoggingOutcome, MethodHandler, PromptGetCommand,
|
||||
PromptsCommand, PromptsListCommand, PromptsOutcome, RequestEra, ResourceReadCommand,
|
||||
ResourcesCommand, ResourcesListCommand, ResourcesOutcome, ServiceContext, SetLevelCommand,
|
||||
ToolCallCommand, ToolsCommand, ToolsListCommand, ToolsOutcome,
|
||||
ambiguous_session_carrier_response, handle_completion_command, handle_logging_command,
|
||||
handle_prompts_command, handle_resources_command, handle_tools_command,
|
||||
resolve_request_identity,
|
||||
CompletionCommand, CompletionOutcome, ContinuationSupport, DispatchDecision,
|
||||
EVENT_LEVEL_APPLIED, EnvelopeKind, INVALID_LEVEL, Kind, LoggingOutcome, MethodHandler,
|
||||
PromptGetCommand, PromptsCommand, PromptsListCommand, PromptsOutcome, RequestEra,
|
||||
ResourceReadCommand, ResourcesCommand, ResourcesListCommand, ResourcesOutcome,
|
||||
ServiceContext, SetLevelCommand, ToolCallCommand, ToolsCommand, ToolsListCommand,
|
||||
ToolsOutcome, ambiguous_session_carrier_response, handle_completion_command,
|
||||
handle_logging_command, handle_prompts_command, handle_resources_command,
|
||||
handle_tools_command, resolve_request_identity,
|
||||
},
|
||||
rate_limit::{rate_limited_jsonrpc_response, rate_limited_status_response},
|
||||
request_context::RequestContext,
|
||||
|
||||
@@ -157,10 +157,9 @@ mod tests {
|
||||
// Every label value of the enum is a pinned literal, so the label domain cannot be widened by
|
||||
// a request at all.
|
||||
assert!(
|
||||
McpMethod::VALUES
|
||||
.iter()
|
||||
.all(|value| value.chars().all(|character| character.is_ascii_lowercase()
|
||||
|| character == '_')),
|
||||
McpMethod::VALUES.iter().all(|value| value
|
||||
.chars()
|
||||
.all(|character| character.is_ascii_lowercase() || character == '_')),
|
||||
"every method label is a fixed lowercase literal: {:?}",
|
||||
McpMethod::VALUES
|
||||
);
|
||||
|
||||
@@ -105,7 +105,10 @@ fn malformed_level_shapes_share_one_safe_detail() {
|
||||
// Control: the same safe detail is what an unknown string produces, so both malformed shapes are
|
||||
// indistinguishable on the wire and neither discloses what was sent.
|
||||
assert_eq!(validate("verbose"), Some(Err(INVALID_LEVEL)));
|
||||
assert!(INVALID_LEVEL.len() < 64, "the detail stays a fixed short text");
|
||||
assert!(
|
||||
INVALID_LEVEL.len() < 64,
|
||||
"the detail stays a fixed short text"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -254,9 +257,7 @@ async fn the_notification_body_is_exactly_the_closed_safe_shape() {
|
||||
|
||||
#[test]
|
||||
fn the_modern_level_is_read_from_the_pinned_meta_key_only() {
|
||||
let modern = |meta: Value| {
|
||||
json!({"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {"_meta": meta}})
|
||||
};
|
||||
let modern = |meta: Value| json!({"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {"_meta": meta}});
|
||||
assert_eq!(
|
||||
modern_request_level(&modern(
|
||||
json!({ "io.modelcontextprotocol/logLevel": "error" })
|
||||
|
||||
@@ -314,9 +314,7 @@ pub(super) fn transport_response(
|
||||
/// error. Every label is a fixed string of the closed vocabulary; nothing from the payload or the
|
||||
/// request is copied into it.
|
||||
fn note_logging_outcome(payload: &Value) {
|
||||
use crate::protocol::{
|
||||
EVENT_FAILED, EVENT_REJECTED, EVENT_SERVED, LogLevel, note,
|
||||
};
|
||||
use crate::protocol::{EVENT_FAILED, EVENT_REJECTED, EVENT_SERVED, LogLevel, note};
|
||||
if payload.get("error").is_some() {
|
||||
match payload.pointer("/error/code").and_then(Value::as_i64) {
|
||||
// The pinned client-error codes of a malformed request.
|
||||
|
||||
Reference in new issue
Block a user