5pm-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 +4 -4
- data/README.md +35 -0
- data/exe/five-pm-mcp +6 -2
- data/lib/five_pm/mcp/project_scope.rb +79 -0
- data/lib/five_pm/mcp/server.rb +13 -3
- data/lib/five_pm/mcp/version.rb +1 -1
- data/sig/five_pm-mcp.rbs +1 -1
- metadata +11 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a7af330a715b94e7facd8689f302e940e34733223f9c0e2d185873e80b962d11
|
|
4
|
+
data.tar.gz: e6bc7ab494f98a488bfbabe0bf8c002c2aa2cd7a4fe8d5f0323bf1e49b517152
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4bc771ef99e8ded0147a50622b3fdd6058d7cb2ae72e53f23ad865374fe0899bab9e36561ac481287f1964e627f13306015406c4b68192e4e3e91d5256495017
|
|
7
|
+
data.tar.gz: b004dbe87ebfb5bb73232a7a05c7cac8994190fb800a0e0a2dfc1ca3c1a4f4f921454d6ef7a7fa358143733aeae82903ff47821c44c8407c27fd84f8b9686cdd
|
data/README.md
CHANGED
|
@@ -118,3 +118,38 @@ Tracks [issue #4](https://github.com/scarver2/5pm-ruby/issues/4). Both packages
|
|
|
118
118
|
subject to review of the tested source and explicit publication approval. Live checks
|
|
119
119
|
exercise the actual read-only stdio executable, all project/task mutation tools in
|
|
120
120
|
an embedding host, per-call approval denial, argument spoofing rejection and audit redaction.
|
|
121
|
+
|
|
122
|
+
## Trusted project scope (0.2.0)
|
|
123
|
+
|
|
124
|
+
Hosts may construct a read-only adapter with a nonempty allowlist of positive
|
|
125
|
+
integer project IDs:
|
|
126
|
+
|
|
127
|
+
```ruby
|
|
128
|
+
FivePM::MCPAdapter::Server.new(client: client, project_ids: [12, 13])
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
The standalone executable accepts the same trusted configuration through
|
|
132
|
+
`FIVE_PM_PROJECT_IDS='[12,13]'`. Supply this in the host environment, never as a
|
|
133
|
+
tool argument. Missing configuration preserves the ten account-visible read
|
|
134
|
+
tools. Invalid or empty configuration exits instead of falling back to unscoped
|
|
135
|
+
access. The array is copied at construction; recreate the adapter after changing
|
|
136
|
+
project membership. Up to 1,000 IDs are supported.
|
|
137
|
+
|
|
138
|
+
Scoped adapters expose only `get_projects`, `get_tasks`, `list_tasks`,
|
|
139
|
+
`get_activity` and `list_activity` (with the `five_pm_` prefix). Account-wide user,
|
|
140
|
+
group and project-list tools are unavailable. Scoped mutations are unavailable,
|
|
141
|
+
even with an approval callback; the existing approval contract still applies to
|
|
142
|
+
unscoped embedded mutations.
|
|
143
|
+
|
|
144
|
+
Task/activity lists inject the project filter when one project is configured.
|
|
145
|
+
With multiple projects, each call must select an allowed `filter.projectId`;
|
|
146
|
+
visit each project and its `next_offset` separately. Conflicting filters fail
|
|
147
|
+
before API dispatch. Direct-ID reads, list pages, missing project identities,
|
|
148
|
+
unexpected returned record IDs and nested `projectId` references are checked
|
|
149
|
+
before data is returned. A mixed or out-of-scope page is rejected in full, rather
|
|
150
|
+
than silently dropping rows and making pagination appear complete.
|
|
151
|
+
|
|
152
|
+
This adapter boundary does not change the account's remote permissions. Use a
|
|
153
|
+
least-privilege account. Unknown fields and account text remain untrusted data;
|
|
154
|
+
project membership can change concurrently and requires an operator-controlled
|
|
155
|
+
scope refresh. Published 0.1.0 does not include this feature.
|
data/exe/five-pm-mcp
CHANGED
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
require "five_pm/mcp"
|
|
3
3
|
|
|
4
4
|
begin
|
|
5
|
+
if ENV.key?("FIVE_PM_PROJECT_IDS")
|
|
6
|
+
project_ids = JSON.parse(ENV.fetch("FIVE_PM_PROJECT_IDS"))
|
|
7
|
+
FivePM::MCPAdapter::ProjectScope.new(project_ids)
|
|
8
|
+
end
|
|
5
9
|
client = FivePM::Client.new(host: ENV.fetch("FIVE_PM_HOST"), login: ENV.fetch("FIVE_PM_LOGIN"),
|
|
6
10
|
password: ENV.fetch("FIVE_PM_PASSWORD"), response_mode: :typed)
|
|
7
11
|
# The executable always runs read-only. Hosts can embed the adapter with a trusted
|
|
8
12
|
# per-call approval callback if they intentionally enable mutation tools.
|
|
9
13
|
audit = ->(event) { $stderr.write("#{JSON.generate(event)}\n") }
|
|
10
|
-
FivePM::MCPAdapter::Server.new(client: client, audit: audit).open
|
|
11
|
-
rescue FivePM::Error, KeyError
|
|
14
|
+
FivePM::MCPAdapter::Server.new(client: client, audit: audit, project_ids: project_ids).open
|
|
15
|
+
rescue FivePM::Error, KeyError, ArgumentError, JSON::ParserError
|
|
12
16
|
warn "5pm MCP configuration or connection failed; check injected environment variables."
|
|
13
17
|
exit 1
|
|
14
18
|
ensure
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
module FivePM
|
|
2
|
+
module MCPAdapter
|
|
3
|
+
# Trusted host configuration. Caller arguments can narrow this boundary,
|
|
4
|
+
# never expand it. Scoped adapters expose only project/task/activity reads.
|
|
5
|
+
class ProjectScope
|
|
6
|
+
def initialize(ids)
|
|
7
|
+
unless ids.is_a?(Array) && !ids.empty? && ids.length <= 1000 &&
|
|
8
|
+
ids.all? { |id| id.is_a?(Integer) && id.positive? }
|
|
9
|
+
raise ArgumentError, "project scope requires positive integer IDs"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
@ids = ids.uniq.freeze
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def visible?(service, action)
|
|
16
|
+
%w[tasks activity].include?(service) || (service == "projects" && action == "get")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def arguments(service, action, supplied)
|
|
20
|
+
if service == "projects"
|
|
21
|
+
require_id(supplied.fetch("id"))
|
|
22
|
+
return supplied
|
|
23
|
+
end
|
|
24
|
+
return supplied unless action == "list"
|
|
25
|
+
|
|
26
|
+
filter = supplied.fetch("filter", {}).dup
|
|
27
|
+
id = filter["projectId"] || (@ids.first if @ids.length == 1)
|
|
28
|
+
require_id(id)
|
|
29
|
+
supplied.merge("filter" => filter.merge("projectId" => id))
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def result(service, action, arguments, data)
|
|
33
|
+
expected = if service == "projects"
|
|
34
|
+
arguments.fetch("id")
|
|
35
|
+
elsif action == "list"
|
|
36
|
+
arguments.fetch("filter").fetch("projectId")
|
|
37
|
+
end
|
|
38
|
+
rows = action == "list" ? data.fetch("items") : [data]
|
|
39
|
+
rows.each do |row|
|
|
40
|
+
raise FivePM::ProtocolError, "missing scoped record" unless row.is_a?(Hash)
|
|
41
|
+
|
|
42
|
+
id = numeric_id(row[service == "projects" ? "id" : "projectId"])
|
|
43
|
+
require_id(id)
|
|
44
|
+
raise FivePM::ProtocolError, "unexpected project in response" if expected && id != expected
|
|
45
|
+
if action == "get" && numeric_id(row["id"]) != arguments.fetch("id")
|
|
46
|
+
raise FivePM::ProtocolError, "unexpected record in response"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
nested(row)
|
|
50
|
+
end
|
|
51
|
+
data
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
private
|
|
55
|
+
|
|
56
|
+
def require_id(id)
|
|
57
|
+
raise ArgumentError, "project outside trusted scope or explicit project required" unless @ids.include?(id)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def numeric_id(value)
|
|
61
|
+
return value if value.is_a?(Integer) && value.positive?
|
|
62
|
+
return Integer(value, 10) if value.is_a?(String) && /\A[1-9]\d*\z/.match?(value)
|
|
63
|
+
|
|
64
|
+
raise FivePM::ProtocolError, "missing project/record identity"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def nested(value)
|
|
68
|
+
case value
|
|
69
|
+
when Hash
|
|
70
|
+
value.each do |key, item|
|
|
71
|
+
require_id(numeric_id(item)) if key == "projectId"
|
|
72
|
+
nested(item)
|
|
73
|
+
end
|
|
74
|
+
when Array then value.each { |item| nested(item) }
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
data/lib/five_pm/mcp/server.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require "json"
|
|
2
|
+
require_relative "project_scope"
|
|
2
3
|
|
|
3
4
|
module FivePM
|
|
4
5
|
module MCPAdapter
|
|
@@ -18,15 +19,18 @@ module FivePM
|
|
|
18
19
|
|
|
19
20
|
# approver is a trusted host callback, never an MCP argument. It receives an
|
|
20
21
|
# immutable exact proposal and must obtain explicit user approval for that call.
|
|
21
|
-
def initialize(client:, allow_mutations: false, approver: nil, audit: ->(_event) {}, allowed_tools: nil
|
|
22
|
+
def initialize(client:, allow_mutations: false, approver: nil, audit: ->(_event) {}, allowed_tools: nil,
|
|
23
|
+
project_ids: nil)
|
|
22
24
|
unless [true, false].include?(allow_mutations) && audit.respond_to?(:call)
|
|
23
25
|
raise ArgumentError, "invalid adapter configuration"
|
|
24
26
|
end
|
|
25
27
|
if allow_mutations && !approver.respond_to?(:call)
|
|
26
28
|
raise ArgumentError, "mutations require a trusted per-call approval callback"
|
|
27
29
|
end
|
|
30
|
+
raise ArgumentError, "project-scoped adapters are read-only" if project_ids && allow_mutations
|
|
28
31
|
|
|
29
32
|
@client = client
|
|
33
|
+
@project_scope = ProjectScope.new(project_ids) unless project_ids.nil?
|
|
30
34
|
@allow_mutations = allow_mutations
|
|
31
35
|
@approver = approver
|
|
32
36
|
@audit = audit
|
|
@@ -80,8 +84,12 @@ module FivePM
|
|
|
80
84
|
reads = RESOURCES.flat_map do |service, (part, filters)|
|
|
81
85
|
properties = { offset: { type: "integer", minimum: 0 }, limit: { type: "integer", minimum: 1, maximum: 100 } }
|
|
82
86
|
properties[:filter] = filter_schema(filters) unless filters.empty?
|
|
83
|
-
[
|
|
84
|
-
|
|
87
|
+
%w[list get].filter_map do |action|
|
|
88
|
+
next if @project_scope && !@project_scope.visible?(service, action)
|
|
89
|
+
|
|
90
|
+
input = action == "list" ? schema(properties) : schema({ id: ID }, ["id"])
|
|
91
|
+
tool("#{action}_#{service}", input, service, action, part, false)
|
|
92
|
+
end
|
|
85
93
|
end
|
|
86
94
|
return reads unless @allow_mutations
|
|
87
95
|
|
|
@@ -116,6 +124,7 @@ module FivePM
|
|
|
116
124
|
def respond(name, service, action, part, mutation, arguments)
|
|
117
125
|
request_id = next_request_id
|
|
118
126
|
wire_arguments = immutable(stringify(arguments))
|
|
127
|
+
wire_arguments = immutable(@project_scope.arguments(service, action, wire_arguments)) if @project_scope
|
|
119
128
|
if mutation
|
|
120
129
|
proposal = immutable({ "tool" => "five_pm_#{name}", "service" => service,
|
|
121
130
|
"action" => action, "arguments" => wire_arguments, "request_id" => request_id })
|
|
@@ -126,6 +135,7 @@ module FivePM
|
|
|
126
135
|
end
|
|
127
136
|
dispatched = true
|
|
128
137
|
data = dispatch(service, action, part, wire_arguments)
|
|
138
|
+
@project_scope&.result(service, action, wire_arguments, data)
|
|
129
139
|
# A successful mutation must never look retryable if an audit sink fails.
|
|
130
140
|
result = response({ data: sanitize(data) })
|
|
131
141
|
audit(request_id, name, "success")
|
data/lib/five_pm/mcp/version.rb
CHANGED
data/sig/five_pm-mcp.rbs
CHANGED
|
@@ -15,7 +15,7 @@ module FivePM
|
|
|
15
15
|
attr_reader server: _ProtocolServer
|
|
16
16
|
def initialize: (client: FivePM::Client, ?allow_mutations: bool,
|
|
17
17
|
?approver: (^(proposal) -> untyped)?, ?audit: ^(audit_event) -> untyped,
|
|
18
|
-
?allowed_tools: Array[String]?) -> void
|
|
18
|
+
?allowed_tools: Array[String]?, ?project_ids: Array[Integer]?) -> void
|
|
19
19
|
def open: () -> untyped
|
|
20
20
|
def inspect: () -> String
|
|
21
21
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: 5pm-mcp
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stan Carver II
|
|
8
|
+
autorequire:
|
|
8
9
|
bindir: exe
|
|
9
10
|
cert_chain: []
|
|
10
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-24 00:00:00.000000000 Z
|
|
11
12
|
dependencies:
|
|
12
13
|
- !ruby/object:Gem::Dependency
|
|
13
14
|
name: 5pm
|
|
@@ -15,14 +16,14 @@ dependencies:
|
|
|
15
16
|
requirements:
|
|
16
17
|
- - "~>"
|
|
17
18
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 0.
|
|
19
|
+
version: 0.2.0
|
|
19
20
|
type: :runtime
|
|
20
21
|
prerelease: false
|
|
21
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
23
|
requirements:
|
|
23
24
|
- - "~>"
|
|
24
25
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 0.
|
|
26
|
+
version: 0.2.0
|
|
26
27
|
- !ruby/object:Gem::Dependency
|
|
27
28
|
name: mcp
|
|
28
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -37,6 +38,8 @@ dependencies:
|
|
|
37
38
|
- - "~>"
|
|
38
39
|
- !ruby/object:Gem::Version
|
|
39
40
|
version: 1.6.1
|
|
41
|
+
description:
|
|
42
|
+
email:
|
|
40
43
|
executables:
|
|
41
44
|
- five-pm-mcp
|
|
42
45
|
extensions: []
|
|
@@ -46,6 +49,7 @@ files:
|
|
|
46
49
|
- README.md
|
|
47
50
|
- exe/five-pm-mcp
|
|
48
51
|
- lib/five_pm/mcp.rb
|
|
52
|
+
- lib/five_pm/mcp/project_scope.rb
|
|
49
53
|
- lib/five_pm/mcp/server.rb
|
|
50
54
|
- lib/five_pm/mcp/version.rb
|
|
51
55
|
- sig/five_pm-mcp.rbs
|
|
@@ -57,6 +61,7 @@ metadata:
|
|
|
57
61
|
source_code_uri: https://github.com/scarver2/5pm-ruby
|
|
58
62
|
rubygems_mfa_required: 'true'
|
|
59
63
|
allowed_push_host: https://rubygems.org
|
|
64
|
+
post_install_message:
|
|
60
65
|
rdoc_options: []
|
|
61
66
|
require_paths:
|
|
62
67
|
- lib
|
|
@@ -71,7 +76,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
71
76
|
- !ruby/object:Gem::Version
|
|
72
77
|
version: '0'
|
|
73
78
|
requirements: []
|
|
74
|
-
rubygems_version:
|
|
79
|
+
rubygems_version: 3.5.22
|
|
80
|
+
signing_key:
|
|
75
81
|
specification_version: 4
|
|
76
82
|
summary: Least-privilege MCP adapter for the 5pm SDK
|
|
77
83
|
test_files: []
|