@tiangong-lca/mcp-server 0.0.6 → 0.0.7

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.
@@ -1,342 +0,0 @@
1
- syntax = "proto3";
2
- package protolca.services;
3
-
4
- option java_package = "org.openlca.proto.generated";
5
- option csharp_namespace = "ProtoLCA.Services";
6
- option go_package = ".;protolca";
7
-
8
- import public "olca.proto";
9
-
10
- message Empty {
11
- }
12
-
13
- message Status {
14
- bool ok = 1;
15
- string error = 2;
16
- }
17
-
18
- message RefStatus {
19
- bool ok = 1;
20
- protolca.Ref ref = 2;
21
- string error = 3;
22
- }
23
-
24
- message ActorStatus {
25
- bool ok = 1;
26
- protolca.Actor actor = 2;
27
- string error = 3;
28
- }
29
-
30
- message CategoryStatus {
31
- bool ok = 1;
32
- protolca.Category category = 2;
33
- string error = 3;
34
- }
35
-
36
- message CurrencyStatus {
37
- bool ok = 1;
38
- protolca.Currency currency = 2;
39
- string error = 3;
40
- }
41
-
42
- message DQSystemStatus {
43
- bool ok = 1;
44
- protolca.DQSystem dq_system = 2;
45
- string error = 3;
46
- }
47
-
48
- message FlowStatus {
49
- bool ok = 1;
50
- protolca.Flow flow = 2;
51
- string error = 3;
52
- }
53
-
54
- message FlowPropertyStatus {
55
- bool ok = 1;
56
- protolca.FlowProperty flow_property = 2;
57
- string error = 3;
58
- }
59
-
60
- message ImpactCategoryStatus {
61
- bool ok = 1;
62
- protolca.ImpactCategory impact_category = 2;
63
- string error = 3;
64
- }
65
-
66
- message ImpactMethodStatus {
67
- bool ok = 1;
68
- protolca.ImpactMethod impact_method = 2;
69
- string error = 3;
70
- }
71
-
72
- message LocationStatus {
73
- bool ok = 1;
74
- protolca.Location location = 2;
75
- string error = 3;
76
- }
77
-
78
- message ParameterStatus {
79
- bool ok = 1;
80
- protolca.Parameter parameter = 2;
81
- string error = 3;
82
- }
83
-
84
- message ProcessStatus {
85
- bool ok = 1;
86
- protolca.Process process = 2;
87
- string error = 3;
88
- }
89
-
90
- message ProductSystemStatus {
91
- bool ok = 1;
92
- protolca.ProductSystem product_system = 2;
93
- string error = 3;
94
- }
95
-
96
- message ProjectStatus {
97
- bool ok = 1;
98
- protolca.Project project = 2;
99
- string error = 3;
100
- }
101
-
102
- message SocialIndicatorStatus {
103
- bool ok = 1;
104
- protolca.SocialIndicator social_indicator = 2;
105
- string error = 3;
106
- }
107
-
108
- message SourceStatus {
109
- bool ok = 1;
110
- protolca.Source source = 2;
111
- string error = 3;
112
- }
113
-
114
- message UnitGroupStatus {
115
- bool ok = 1;
116
- protolca.UnitGroup unit_group = 2;
117
- string error = 3;
118
- }
119
-
120
- // DescriptorRequest is a message type for getting descriptors from the data
121
- // service. Note that all fields are optional and can have different meanings
122
- // depending on the service function.
123
- message DescriptorRequest {
124
-
125
- // The model type of the requested descriptor(s).
126
- ModelType type = 1;
127
-
128
- // The ID of the requested descriptor.
129
- string id = 2;
130
-
131
- // The name of the requested descriptor(s).
132
- string name = 3;
133
-
134
- // The ID or full path of the category.
135
- string category = 4;
136
- }
137
-
138
- message SearchRequest {
139
-
140
- // The model type of the searched entities.
141
- ModelType type = 1;
142
-
143
- // The search query.
144
- string query = 2;
145
- }
146
-
147
- message CreateSystemRequest {
148
-
149
- enum DefaultProviders {
150
- Prefer = 0;
151
- Ignore = 1;
152
- Only = 2;
153
- }
154
-
155
- // The (reference of the) process from which the product system should be
156
- // generated. This will be the reference process of the product system
157
- // with upstream and downstream processes added recursively.
158
- Ref process = 1;
159
-
160
- // Indicates how default providers of product inputs and waste outputs
161
- // should be considered during the linking. `only` means that only
162
- // product inputs and waste outputs should be linked that have a
163
- // default provider and that this default provider is used. `prefer`
164
- // means that a default provider is used during the linking if there
165
- // are multiple options. `ignore` means that the default providers
166
- // have no specific role.
167
- DefaultProviders default_providers = 2;
168
-
169
- // When there are multiple provider processes available for linking a
170
- // product input or waste output the `preferred_type` indicates which
171
- // type of process (LCI results or unit processes) should be preferred
172
- // during the linking.
173
- ProcessType preferred_type = 3;
174
- }
175
-
176
- service DataService {
177
-
178
- // Deletes the object with the `id` and `type` of the given descriptor from
179
- // the database. Note that the type is a string with the name of the
180
- // corresponding model class, e.g. `Process` or `Flow`.
181
- rpc Delete(protolca.Ref) returns (Status);
182
-
183
- // Get all descriptors that match the given request.
184
- rpc GetDescriptors(DescriptorRequest) returns (stream Ref);
185
-
186
- // Get the first descriptor that matches the given request.
187
- rpc GetDescriptor(DescriptorRequest) returns (RefStatus);
188
-
189
- // Search for data sets.
190
- rpc Search(SearchRequest) returns (stream Ref);
191
-
192
- // Creates a new product system.
193
- rpc CreateProductSystem(CreateSystemRequest) returns (RefStatus);
194
-
195
- // methods for Actor
196
- rpc GetActors(Empty) returns (stream protolca.Actor);
197
- rpc GetActor(protolca.Ref) returns (ActorStatus);
198
- rpc PutActor(protolca.Actor) returns (RefStatus);
199
-
200
- // methods for Category
201
- rpc GetCategories(Empty) returns (stream protolca.Category);
202
- rpc GetCategory(protolca.Ref) returns (CategoryStatus);
203
- rpc PutCategory(protolca.Category) returns (RefStatus);
204
-
205
- // methods for Currency
206
- rpc GetCurrencies(Empty) returns (stream protolca.Currency);
207
- rpc GetCurrency(protolca.Ref) returns (CurrencyStatus);
208
- rpc PutCurrency(protolca.Currency) returns (RefStatus);
209
-
210
- // methods for DQSystem
211
- rpc GetDQSystems(Empty) returns (stream protolca.DQSystem);
212
- rpc GetDQSystem(protolca.Ref) returns (DQSystemStatus);
213
- rpc PutDQSystem(protolca.DQSystem) returns (RefStatus);
214
-
215
- // methods for Flow
216
- rpc GetFlows(Empty) returns (stream protolca.Flow);
217
- rpc GetFlow(protolca.Ref) returns (FlowStatus);
218
- rpc PutFlow(protolca.Flow) returns (RefStatus);
219
-
220
- // methods for FlowProperty
221
- rpc GetFlowProperties(Empty) returns (stream protolca.FlowProperty);
222
- rpc GetFlowProperty(protolca.Ref) returns (FlowPropertyStatus);
223
- rpc PutFlowProperty(protolca.FlowProperty) returns (RefStatus);
224
-
225
- // methods for ImpactCategory
226
- rpc GetImpactCategories(Empty) returns (stream protolca.ImpactCategory);
227
- rpc GetImpactCategory(protolca.Ref) returns (ImpactCategoryStatus);
228
- rpc PutImpactCategory(protolca.ImpactCategory) returns (RefStatus);
229
-
230
- // methods for ImpactMethod
231
- rpc GetImpactMethods(Empty) returns (stream protolca.ImpactMethod);
232
- rpc GetImpactMethod(protolca.Ref) returns (ImpactMethodStatus);
233
- rpc PutImpactMethod(protolca.ImpactMethod) returns (RefStatus);
234
-
235
- // methods for Location
236
- rpc GetLocations(Empty) returns (stream protolca.Location);
237
- rpc GetLocation(protolca.Ref) returns (LocationStatus);
238
- rpc PutLocation(protolca.Location) returns (RefStatus);
239
-
240
- // methods for Parameter
241
- rpc GetParameters(Empty) returns (stream protolca.Parameter);
242
- rpc GetParameter(protolca.Ref) returns (ParameterStatus);
243
- rpc PutParameter(protolca.Parameter) returns (RefStatus);
244
-
245
- // methods for Process
246
- rpc GetProcesses(Empty) returns (stream protolca.Process);
247
- rpc GetProcess(protolca.Ref) returns (ProcessStatus);
248
- rpc PutProcess(protolca.Process) returns (RefStatus);
249
-
250
- // methods for ProductSystem
251
- rpc GetProductSystems(Empty) returns (stream protolca.ProductSystem);
252
- rpc GetProductSystem(protolca.Ref) returns (ProductSystemStatus);
253
- rpc PutProductSystem(protolca.ProductSystem) returns (RefStatus);
254
-
255
- // methods for Project
256
- rpc GetProjects(Empty) returns (stream protolca.Project);
257
- rpc GetProject(protolca.Ref) returns (ProjectStatus);
258
- rpc PutProject(protolca.Project) returns (RefStatus);
259
-
260
- // methods for SocialIndicator
261
- rpc GetSocialIndicators(Empty) returns (stream protolca.SocialIndicator);
262
- rpc GetSocialIndicator(protolca.Ref) returns (SocialIndicatorStatus);
263
- rpc PutSocialIndicator(protolca.SocialIndicator) returns (RefStatus);
264
-
265
- // methods for Source
266
- rpc GetSources(Empty) returns (stream protolca.Source);
267
- rpc GetSource(protolca.Ref) returns (SourceStatus);
268
- rpc PutSource(protolca.Source) returns (RefStatus);
269
-
270
- // methods for UnitGroup
271
- rpc GetUnitGroups(Empty) returns (stream protolca.UnitGroup);
272
- rpc GetUnitGroup(protolca.Ref) returns (UnitGroupStatus);
273
- rpc PutUnitGroup(protolca.UnitGroup) returns (RefStatus);
274
-
275
- // Get possible providers for the given flow. For products
276
- // these are processes with that product on the output side
277
- // and for waste flows processes with that waste flow on the
278
- // input side. For elementary flows, an empty stream is
279
- // returned.
280
- rpc GetProvidersFor(Ref) returns (stream Ref);
281
- }
282
-
283
- message FlowMapStatus {
284
- bool ok = 1;
285
- protolca.FlowMap flow_map = 2;
286
- string error = 3;
287
- }
288
-
289
- message FlowMapInfo {
290
- string name = 1;
291
- }
292
-
293
- service FlowMapService {
294
-
295
- // Delete the flow map with the given name.
296
- rpc Delete(FlowMapInfo) returns (Status);
297
-
298
- // Get the flow map with the given name form the
299
- // database.
300
- rpc Get(FlowMapInfo) returns (FlowMapStatus);
301
-
302
- // Get the information (basically just the names) of all
303
- // flow maps that are available in the database.
304
- rpc GetAll(Empty) returns (stream FlowMapInfo);
305
-
306
- // Inserts the given flow map into the database. It overwrites
307
- // an existing flow map if there is a flow map with the same
308
- // name already available in the database.
309
- rpc Put(protolca.FlowMap) returns (Status);
310
- }
311
-
312
- // A `Result` message is basically just a reference to a real result on the
313
- // server side. As result data can be really large, we do not add them directly
314
- // to the result. Instead you call the respective methods of the result service
315
- // to get them. Because of this, you need to explicitly call `Dispose` when
316
- // you do not need a result anymore. Otherwise you will create memory leaks
317
- // as the result still exists on the server side.
318
- message Result {
319
- string id = 1 [json_name = "@id"];
320
- }
321
-
322
- message ResultStatus {
323
- bool ok = 1;
324
- Result result = 2;
325
- string error = 3;
326
- }
327
-
328
- service ResultService {
329
-
330
- // Calculates a result for the given calculation setup.
331
- rpc Calculate(CalculationSetup) returns (ResultStatus);
332
-
333
- // Get the inventory of the given result.
334
- rpc GetInventory(Result) returns (stream FlowResult);
335
-
336
- // Get the total impact assessment result of the given result.
337
- rpc GetImpacts(Result) returns (stream ImpactResult);
338
-
339
- // Disposes the given result on the server side.
340
- rpc Dispose(Result) returns (Status);
341
-
342
- }
@@ -1,46 +0,0 @@
1
- import * as loader from '@grpc/proto-loader';
2
- import * as grpc from '@grpc/grpc-js';
3
- const protos = loader.loadSync('/root/projects/tiangong-lca-mcp/dist/src/tools/_shared/services.proto', { enums: String });
4
- const protolca = grpc.loadPackageDefinition(protos).protolca;
5
- const URL = '192.168.1.108:8080';
6
- function printContent() {
7
- const data = new protolca.services.DataService(URL, grpc.credentials.createInsecure());
8
- data.getImpactMethods({})
9
- .on('data', (method) => console.log(`impact method: id = ${method.id}, name = ${method.name}`));
10
- data.getProductSystems({})
11
- .on('data', (system) => console.log(`product system: id = ${system.id}, name = ${system.name}`));
12
- }
13
- function calculationExample() {
14
- const results = new protolca.services.ResultService(URL, grpc.credentials.createInsecure());
15
- var setup = {
16
- productSystem: { id: '66344e38-411a-4996-8062-e92dd3cd211c' },
17
- impactMethod: { id: '9a597be4-ce40-4acd-9ace-ca8edebce13f' },
18
- };
19
- results.calculate(setup, (err, response) => {
20
- if (err) {
21
- console.log('calculation failed', err);
22
- return;
23
- }
24
- const result = response.result;
25
- const impacts = results.getImpacts(result);
26
- impacts.on('data', (impact) => {
27
- const s = impact.impactCategory.name
28
- + ': ' + impact.value
29
- + ' ' + impact.impactCategory.refUnit;
30
- console.log(s);
31
- });
32
- impacts.on('end', () => {
33
- results.dispose(result, (err) => {
34
- if (err) {
35
- console.log('failed to dispose result', err);
36
- return;
37
- }
38
- console.log('disposed result');
39
- });
40
- });
41
- });
42
- }
43
- function main() {
44
- printContent();
45
- }
46
- main();