top | item 44849325

(no title)

cle | 6 months ago

I don't understand this criticism by the author. MCP supports JSON Schema, and server responses must conform to the schema. If the schema requires an ISO-8601 timestamp (ex by specifying a "date" format in the schema) but the server sends a Unix epoch timestamp, then it is violating the protocol.

The author even later says that MCP supports JSON Schema, but also claims "you can't generate type-safe clients". Which is plainly untrue, there exist plenty of JSON Schema code generators.

discuss

order

ohdeargodno|6 months ago

Except that any properly written software will respond to protocol and schema violations by throwing an error.

Claude will happily cast your int into a 2023 Toyota Yaris and keep on hallucinating things.

starkparker|6 months ago

For the curious:

> Cast an integer into the type of a 2023 Toyota Yaris using Javascript

(GPT-4o mini)

> To cast an integer into the type of a 2023 Toyota Yaris in JavaScript, you would typically create a class or a constructor function that represents the Toyota Yaris. Then, you can create an instance of that class using the integer value. Here's an example of how you might do this:

  // Define a class for the 2023 Toyota Yaris
  class ToyotaYaris {
      constructor(modelYear, value) {
          this.modelYear = modelYear;
          this.value = value;
      }
  
      displayInfo() {
          console.log(`Model Year: ${this.modelYear}, Value: ${this.value}`);
      }
  }
  
  // Function to cast an integer into a Toyota Yaris object
  function castToYaris(integerValue) {
      const modelYear = 2023; // Set the model year
      return new ToyotaYaris(modelYear, integerValue);
  }
  
  // Example usage
  const integerValue = 20000; // Example integer value
  const yaris = castToYaris(integerValue);
  yaris.displayInfo(); // Output: Model Year: 2023, Value: $20000

cle|6 months ago

I just tried this in Claude Code. I made an MCP server whose tool output is declared as an integer but it returns a string at runtime.

Claude Code validated the response against the schema and did not pass the response to the LLM.

     test - test_tool (MCP)(input: "foo")
      ⎿  Error: Output validation error: 'bar' is not of type 'integer'

dboreham|6 months ago

imho it's a fantasy to expect type safe protocols except in the case that both client and server are written in the same (type safe) language. Actually even that doesn't work. What language actually allows a type definition for "ISO-8601 timestamp" that's complete? Everything ends up being some construction of strings and numbers, and it's often not possible to completely describe the set of valid values except by run-time checking, certainly beyond trivial cases like "integer between 0 and 10".

mgh95|6 months ago

> What language actually allows a type definition for "ISO-8601 timestamp" that's complete?

It is absolutely possible to do this, and to generate client code which complies with ISO-8601 in JS/TS. Large amounts of financial services would not work if this was not the case.

See the c# support for ISO-8601 strings: https://learn.microsoft.com/en-us/dotnet/standard/base-types...

cle|6 months ago

Generally you'd use a time library to model ISO-8601 dates in a typesafe way. Some fancier languages might have syntactic support for it, but they ultimately serve the same purpose.

Related but distinct from serialization.

int_19h|6 months ago

Not only it's possible, but it has been done many times before, and a lot of modern business software is still built on that. You know that old fashioned XML thing? It has schemas, and those schemas come with a lot of predefined types including, specifically, a whole family of ISO 8601-related types:

https://www.w3.org/TR/xmlschema-2/#isoformats

And so you can write a web service in Java and use it from C#, or whatever.

xpe|6 months ago

Let's not focus on 100% or nothing. Let's focus on better and worse.

jongjong|6 months ago

At its core, the article was just ramblings from someone being upset that LLMs didn't make things more complicated so that they could charge more billable hours to solve invented corporate problems... Which some people built their career on.

The merchants of complexity are disappointed. It turns out that even machines don't care for 'machine-readable' formats; even the machines prefer human-readable formats.

The only entities on this planet who appreciate so-called 'machine-readability' are bureaucrats; and they like it for the same reason that they like enterprise acronyms... Literally the opposite of readability.

nxobject|6 months ago

I look forward to waiting a decade and seeing what MCP ends up reinventing.