tiny_mcp 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d3ff46332bafaed3f77ab40c84bf5057a3e1db50ef94ae0bf7116fcc5acfc10
4
- data.tar.gz: 6172e0eb037331572c7fdb44a97bc47e312f5addc801c8e3fe7b7778f2bd6dee
3
+ metadata.gz: d527f6fa5f9f2ba2cfca4d15db75ea9ee40058074a968b9a0dfed8a3edccf5df
4
+ data.tar.gz: 12fda59be8a8fc3c17cbcc3ad9b0e76a46f4b458a1be2412bb9e95fd3e7791b6
5
5
  SHA512:
6
- metadata.gz: a4a38fd1aa93d06ccedb1753ed91242d8f43fcf5892b1ed0aedaaa1b7de7815889ca0737decd659477eb9db53d5edf9304e981fee1ab92b90770aac035d156d4
7
- data.tar.gz: 3241f7c94c8e95fd80f19b4a8e45e5e272a675b2051197627521ac1c4e758afd6461cf8f1cb714bc9a1a574f0d495d778c7cc5e9d312a2e0683a20f49ca8e0a1
6
+ metadata.gz: 249e10b46c99a97a888d848a54fc8b681da48dba3ba0aa7030ea3f47cab5793e39257b2fb523bb7d906e4fa9c49a625bcda9f310d806bdbfb2ec7097692beac6
7
+ data.tar.gz: c8ff441413575551618d944eb9192506a5f3fedaebe02fe574b2e8f68b54973aedb4ec5cb6c961ab73539979581dacfc8321d9d8a4d943f5c1e01ff8c09c9eb3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.0] - 2025-06-07
4
+
5
+ - Add support for multi-result responses of any formats
6
+
3
7
  ## [0.1.0] - 2025-05-26
4
8
 
5
9
  - Initial release
data/README.md CHANGED
@@ -19,10 +19,10 @@ require 'tiny_mcp'
19
19
  class WeatherTool < TinyMCP::Tool
20
20
  name 'get_weather'
21
21
  desc 'Get current weather for a city'
22
- arg :city, :string, 'City name'
23
- opt :units, :string, 'Temperature units (celsius/fahrenheit)'
22
+ arg :city, :string, 'City name' # required
23
+ opt :units, :string, 'Temperature units (c/f)' # optional
24
24
 
25
- def call(city:, units: 'celsius')
25
+ def call(city:, units: 'c')
26
26
  # Your implementation here
27
27
  "Weather in #{city}: 20°C, sunny"
28
28
  end
@@ -34,7 +34,7 @@ class TimeTool < TinyMCP::Tool
34
34
  opt :timezone, :string, 'Timezone name'
35
35
 
36
36
  def call(timezone: 'UTC')
37
- Time.now.getlocal(timezone).to_s
37
+ Time.now.getlocal(timezone)
38
38
  end
39
39
  end
40
40
 
@@ -42,7 +42,7 @@ end
42
42
  TinyMCP.serve(WeatherTool, TimeTool)
43
43
  ```
44
44
 
45
- You can put this in a bin/mcp file for example, and make it executable:
45
+ You can put this in a `bin/mcp` file for example, and make it executable:
46
46
 
47
47
  ```bash
48
48
  chmod +x bin/mcp
@@ -54,7 +54,41 @@ Then add it to Claude Code:
54
54
  claude mcp add my-mcp bin/mcp
55
55
  ```
56
56
 
57
- The server reads JSON-RPC requests from stdin and writes responses to stdout, making it compatible with MCP clients.
57
+ The server reads JSON-RPC requests from stdin and writes responses to stdout.
58
+
59
+ ## Multiple results and different formats
60
+
61
+ By default TinyMCP assumes you're returning `text` from your call function. If you want to return image, audio, or a bunch of different results, wrap your return value in an array, and TinyMCP will treat your return value as the whole `content` body.
62
+
63
+ Don't forget that binary data such as images and audio needs to be Base64-encoded.
64
+
65
+ ```ruby
66
+ require 'base64'
67
+
68
+ class MultiModalTool < TinyMCP::Tool
69
+ name 'get_different_formats'
70
+ desc 'Get results in different formats'
71
+
72
+ def call
73
+ [
74
+ {
75
+ type: 'text',
76
+ data: 'This is a text response'
77
+ },
78
+ {
79
+ type: 'image',
80
+ mimeType: 'image/png',
81
+ data: Base64.strict_encode64(File.read('image.png', 'rb'))
82
+ },
83
+ {
84
+ type: 'audio',
85
+ mimeType: 'audio/mpeg',
86
+ data: Base64.strict_encode64(File.read('audio.mp3', 'rb'))
87
+ }
88
+ ]
89
+ end
90
+ end
91
+ ```
58
92
 
59
93
  ## Development
60
94
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TinyMCP
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
data/lib/tiny_mcp.rb CHANGED
@@ -108,15 +108,17 @@ module TinyMCP
108
108
  tool = @tools.find { _1.class.mcp.name == name }
109
109
 
110
110
  if !tool
111
- return error_for(request, :invalid_params, "Unknown_tool: #{name}")
111
+ return error_for(request, :invalid_params, "Unknown tool: #{name}")
112
112
  end
113
113
 
114
114
  args = request.dig('params', 'arguments')&.transform_keys(&:to_sym)
115
115
 
116
116
  begin
117
117
  result = tool.call(**args)
118
- # TODO: Support other content types (ask claude code which ones).
119
- response_for(request, content: [{ type: 'text', text: result.to_s }])
118
+
119
+ result.is_a?(Array) ?
120
+ response_for(request, content: result) :
121
+ response_for(request, content: [{ type: 'text', text: result.to_s }])
120
122
  rescue => e
121
123
  error_for(request, :internal, e.full_message(highlight: false))
122
124
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny_mcp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Chernyak
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-26 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: Make local MCP tools in Ruby and easily serve them.
13
13
  email:
@@ -46,7 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  requirements: []
49
- rubygems_version: 3.6.3
49
+ rubygems_version: 3.6.9
50
50
  specification_version: 4
51
51
  summary: Tiny Ruby-based MCP server
52
52
  test_files: []